Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. $.post("getdata.php")
  2. .done(function(locations) {
  3. var map = new google.maps.Map(document.getElementById('map'), {
  4. zoom: 7,
  5. center: new google.maps.LatLng(LAT, LONG),
  6. mapTypeId: google.maps.MapTypeId.ROADMAP
  7. });
  8.  
  9. var infowindow = new google.maps.InfoWindow();
  10.  
  11. var marker, i;
  12.  
  13. for (i = 0; i < locations.length; i++) {
  14. marker = new google.maps.Marker({
  15. position: new google.maps.LatLng(locations[i][1], locations[i][2]),
  16. map: map
  17. });
  18.  
  19. google.maps.event.addListener(marker, 'click', (function(marker, i) {
  20. return function() {
  21. infowindow.setContent(locations[i][0]);
  22. infowindow.open(map, marker);
  23. }
  24. })(marker, i));
  25. }
  26. });
  27.  
  28. $.post("getdata.php")
  29. .done(function(_locations) {
  30. locations = jQuery.parseJSON(_locations);
  31. var map = new google.maps.Map(document.getElementById('map'), {
  32. zoom: 7,
  33. center: new google.maps.LatLng(LAT, LONG),
  34. mapTypeId: google.maps.MapTypeId.ROADMAP
  35. });
  36.  
  37. var infowindow = new google.maps.InfoWindow();
  38.  
  39. var marker, i;
  40.  
  41. for (i = 0; i < locations.length; i++) {
  42. marker = new google.maps.Marker({
  43. position: new google.maps.LatLng(locations[i][1], locations[i][2]),
  44. map: map
  45. });
  46.  
  47. google.maps.event.addListener(marker, 'click', (function(marker, i) {
  48. return function() {
  49. infowindow.setContent(locations[i][0]);
  50. infowindow.open(map, marker);
  51. }
  52. })(marker, i));
  53. }
  54. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement