Show google Map using Address with PHP

  <?php
  $location = 'chandigarh';
  $address = urlencode($location);
  $request_url = "http://maps.googleapis.com/maps/api/geocode/xml?address=".$address."&sensor=true";
  $xml = simplexml_load_file($request_url) or die("url not loading");
  $status = $xml->status;
  if ($status=="OK") {
      $ravilat = $xml->result->geometry->location->lat;
      $ravilon = $xml->result->geometry->location->lng;      
  }
?>
<script src="http://maps.googleapis.com/maps/api/js"></script>
<script>
function initialize() {

var grayStyles = [
        {
          featureType: "all",
          stylers: [
           { hue: '#aaaaaa' },
      { lightness: -15 },
      { saturation: 99 }
          ]
        },
      ];


  var mapProp = {
    center:new google.maps.LatLng(<?php echo $ravilat; ?>,<?php echo $ravilon; ?>),
    zoom:10,
styles: grayStyles,
panControl:false,
zoomControl:false,
mapTypeControl:false,
disableDefaultUI:true,
streetViewControl:false,
    mapTypeId:google.maps.MapTypeId.ROADMAP
  };
  var map=new google.maps.Map(document.getElementById("ravigoogleMap"),mapProp);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<div id="ravigoogleMap" style="width:100%;height:400px;"></div>

Popular posts from this blog

How to open cPanel using WHM access.

Cant use dump() function in twig files or how to enable debug in opencart twig or print_r alternate use dump() in opencart 3.0