Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. var map = null;
  2. var caminho;
  3. $.ajax({
  4. type: 'GET',
  5. url: url+'posto.php',
  6. dataType: 'html',
  7. data: 'acao=listar',
  8. success: function(data){
  9. caminho = data;
  10. }
  11. });
  12. var markerArray = []; //create a global array to store markers
  13. var locations = caminho;
  14.  
  15. function initialize() {
  16. var myOptions = {
  17. zoom: 10,
  18. center: new google.maps.LatLng(-17.8083, -50.9144),
  19. mapTypeControl: true,
  20. mapTypeControlOptions: {
  21. style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
  22. },
  23. navigationControl: true,
  24. mapTypeId: google.maps.MapTypeId.ROADMAP
  25. }
  26. map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  27.  
  28. google.maps.event.addListener(map, 'click', function() {
  29. infowindow.close();
  30. });
  31.  
  32. // Add markers to the map
  33. // Set up markers based on the number of elements within the myPoints array
  34. for (var i = 0; i < locations.length; i++) {
  35. createMarker(new google.maps.LatLng(locations[i][1], locations[i][2]),locations[i][0], locations[i][3], locations[i][4]);
  36. }
  37.  
  38. mc.addMarkers(markerArray, true);
  39. }
  40.  
  41. var infowindow = new google.maps.InfoWindow({
  42. size: new google.maps.Size(150, 50)
  43. });
  44.  
  45. function createMarker(latlng, myTitle, myIcon) {
  46. var contentString = myTitle;
  47. var marker = new google.maps.Marker({
  48. position: latlng,
  49. map: map,
  50. icon: myIcon,
  51. zIndex: Math.round(latlng.lat() * -100000) << 5,
  52. title: myTitle
  53. });
  54.  
  55. google.maps.event.addListener(marker, 'click', function() {
  56. infowindow.setContent(contentString);
  57. infowindow.open(map, marker);
  58. });
  59.  
  60. markerArray.push(marker); //push local var marker into global array
  61. }
  62.  
  63. //window.onload = initialize;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement