Google map with latitude and longitude Reviewed by Momizat on . [php] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ht [php] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ht Rating: 0

Google map with latitude and longitude

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<div id="map" style="width: 450px; height: 400px; margin:10px;"></div>
</body>

<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
    var locations = [
      ['Address', 33.126247700000000000, -117.311576699999990000, 1],
      ['Address-1', 32.763942000000000000, -117.223503999999990000, 2],
      ['Address-2', 33.097445800000000000, -116.995722699999990000, 3],
      ['Address-3', 32.735316000000000000, -117.149046000000000000, 4],
      ['Address-4', 33.81022, -117.916828, 5],
	  ['Address-5', 33.843472500000000000, -117.998829699999990000, 6]
    ];

    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 8,
      center: new google.maps.LatLng(33.2333, -117.311),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var infowindow = new google.maps.InfoWindow();

    var marker, i;

    for (i = 0; i < locations.length; i++) {  
      marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][1], locations[i][2]),
        map: map
      });

      google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
          infowindow.setContent(locations[i][0]);
          infowindow.open(map, marker);
        }
      })(marker, i));
    }
  </script>
</html>

Leave a Comment

© 2014 Powered By