$prop_mapaddress
contains your textfield value:
<?php
if(isset($prop_mapaddress)) {
global $post;
global $wpdb;
$fromat_address = trim($prop_mapaddress);
$fromat_address = str_replace(" ","+",$fromat_address);
$address_obj = file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?address=".$fromat_address."&sensor=false");
$address_obj =json_decode($address_obj);
$latitude = $address_obj->results[0]->geometry->location->lat;
$longitude = $address_obj->results[0]->geometry->location->lng;
?>
<script>
var geocoder;
var map;
var lat = "<?php echo $latitude ?>";
var lng = "<?php echo $longitude; ?>";
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(lat, lng);
var mapOptions = {
zoom: 15,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
} // map-convas would be id of div you want to show your map in
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<?php
}
?>
Also don’t forget to enqueue Google API script before actually loading map:
wp_enqueue_script('google-map-api','https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false');