Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <script type="text/javascript">
  2.  
  3. var map = new google.maps.Map(document.getElementById('map'), {
  4. zoom: 17,
  5. center: new google.maps.LatLng(3.723, 103.1240),
  6. mapTypeId: google.maps.MapTypeId.ROADMAP
  7. });
  8.  
  9. document.getElementById("demo").innerHTML = initMap(map);
  10.  
  11. function initMap(map) {
  12. var infowindow = new google.maps.InfoWindow();
  13.  
  14. var marker, i;
  15.  
  16. for (i = 0; i < locations.length; i++) {
  17. marker = new google.maps.Marker({
  18. position: new google.maps.LatLng(locations[i][1], locations[i][2]),
  19. map: map
  20. });
  21.  
  22. google.maps.event.addListener(marker, 'click', (function(marker, i) {
  23. return function() {
  24. infowindow.setContent(locations[i][0]);
  25. infowindow.open(map, marker);
  26. }
  27. })(marker, i));
  28. }
  29.  
  30. }//initMap
  31. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement