Google Map with Address by using PHP

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3. <head>  
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  5. <title>Untitled Document</title>  
  6. <style type="text/css">  
  7. html, body, #map-canvas { height: 100%; margin: 0; }  
  8. </style>  
  9. <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>  
  10. <script type="text/javascript">  
  11. var geocoder;  
  12. var map;  
  13. var address ="<?php echo "Sector 60 Noida"; ?>";  

  14. function initialize()
  15. {  
  16.       geocoder = new google.maps.Geocoder();  
  17.       var latlng = new google.maps.LatLng(-34.397, 150.644);  
  18.       var myOptions = {  zoom: 15,  center: latlng,  mapTypeControl: true,  
  19.                          mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},  
  20.                          navigationControl: true,  
  21.                          mapTypeId: google.maps.MapTypeId.ROADMAP };
     
  22.       map = new google.maps.Map(document.getElementById("map-canvas"), myOptions);  
  23.       if (geocoder)
  24.       {  
  25.             geocoder.geocode( { 'address': address}, 
  26.             function(results, status) 
  27.             {  
  28.                   if (status == google.maps.GeocoderStatus.OK)
  29.                   {
  30.                         if (status != google.maps.GeocoderStatus.ZERO_RESULTS)
  31.                         {  
  32.                               map.setCenter(results[0].geometry.location);  
  33.                               var infowindow = new google.maps.InfoWindow(  
  34.                               { content: '<b>'+address+'</b>',  
  35.                               size: new google.maps.Size(150,50)});  
  36.                               var marker = new google.maps.Marker({  
  37.                               position: results[0].geometry.location,  
  38.                               map: map,  
  39.                               title:address });  
  40.                               google.maps.event.addListener(marker, 'click'
  41.                               function()
  42.                               {
  43.                                    infowindow.open(map,marker);  
  44.                               });  
  45.                          }
  46.                          else
  47.                          {  
  48.                               alert("No results found");  
  49.                          }  
  50.                   } 
  51.                   else
  52.                   {
  53.   
  54.                         alert("Geocode was not successful for the following reason: " + status);  
  55.                   }  
  56.             });  
  57.       }  
  58. }  
  59. </script>  
  60. </head>  
  61. <body onload="initialize();">  
  62. <div id="map-canvas"></div>  
  63. </body>  
  64. </html>