Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> google maps i filtrowanie markerów
qbas-s
post
Post #1





Grupa: Zarejestrowani
Postów: 304
Pomógł: 1
Dołączył: 28.06.2009

Ostrzeżenie: (0%)
-----


mam wiele markerów na mapie w różnych obszarach świata. Markery pokazują punkty dystrybucyjne. Puntów o nazwie "xyz" może być wiele w dowolnej lokalizacji na świecie. Jak zrobić aby po wybraniu z listy rozwijanej "xyz" pokazywały się tylko punkty dystrybutora "xyz"?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
qbas-s
post
Post #2





Grupa: Zarejestrowani
Postów: 304
Pomógł: 1
Dołączył: 28.06.2009

Ostrzeżenie: (0%)
-----


nie mogę usuwać markerów po zoomowaniu bo to trochę mija się z celem - chce usunąć wszystkie a potem dodać tylko wybrane. Możecie mi wskazać co robię źle, że po zoomie pojawiają się na nowo markery? To jest wersja robocza więc trochę bałaganu jest.

[JAVASCRIPT] pobierz, plaintext
  1.  
  2. var geocoder;
  3. var map;
  4. var markers = [];
  5. var myLatlng;
  6. var position;
  7.  
  8. function setAllMap(map) {
  9. for (var i = 0; i < markers.length; i++) {
  10. markers[i].setMap(map);
  11. }
  12. }
  13.  
  14. function clearMarkers() {
  15. setAllMap(null);
  16. }
  17.  
  18. function deleteMarkers() {
  19. clearMarkers();
  20. marker = [];
  21. }
  22.  
  23.  
  24. function initialize(address, zoome) {
  25. var activeWindow;
  26.  
  27. geocoder = new google.maps.Geocoder();
  28.  
  29. var mapOptions = {
  30. zoom: zoome,
  31. center: position,
  32. mapTypeId: google.maps.MapTypeId.ROADMAP
  33. }
  34.  
  35. map = new google.maps.Map(document.getElementById("company_map"), mapOptions);
  36.  
  37. showAddress(address, zoome);
  38.  
  39.  
  40.  
  41. var fluster = new Fluster2(map);
  42. {/literal}
  43. {foreach from=$company->list.markers item=i key=k}
  44. {literal}
  45. var infoWindow{/literal}{$k}{literal} = new google.maps.InfoWindow({
  46. content: '{/literal}<span class="testowo" style="font-size:12px"><strong>{$i.name}</strong><br/>{$i.zip} {$i.city}<br/>{$i.address}<br/>{$i.phone} {$i.email}{literal}</span>'
  47. });
  48. {/literal}
  49. {/foreach}
  50. {literal}
  51. {/literal}
  52.  
  53. {foreach from=$company->list.markers item=i key=k}
  54. {literal}
  55. var marker{/literal}{$k}{literal} = new google.maps.Marker({
  56. position: new google.maps.LatLng({/literal}{$i.lat}{literal}, {/literal}{$i.lan}{literal}),
  57. title: '{/literal}{$i.name}{literal}'
  58. });
  59. markers.push(marker{/literal}{$k}{literal});
  60. google.maps.event.addListener(marker{/literal}{$k}{literal}, 'click', function() {
  61. if (activeWindow != null)
  62. activeWindow.close();
  63. infoWindow{/literal}{$k}{literal}.open(map, marker{/literal}{$k}{literal});
  64. //infoWindow{/literal}{$k}{literal}.open(map, marker{/literal}{$k}{literal});
  65. activeWindow = infoWindow{/literal}{$k}{literal};
  66. });
  67. // Add the marker to the Fluste r
  68. fluster.addMarker(marker{/literal}{$k}{literal});
  69.  
  70. {/literal}
  71. {/foreach}
  72.  
  73. {literal}
  74.  
  75.  
  76. fluster.styles = {
  77.  
  78. 0: {
  79. image: 'http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/m1.png',
  80. textColor: '#FFFFFF',
  81. width: 53,
  82. height: 52,
  83. },
  84.  
  85. 10: {
  86. image: 'http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/m2.png',
  87. textColor: '#FFFFFF',
  88. width: 56,
  89. height: 55
  90. },
  91. 20: {
  92. image: 'http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/m3.png',
  93. textColor: '#FFFFFF',
  94. width: 66,
  95. height: 65
  96. }
  97. };
  98.  
  99.  
  100. fluster.initialize();
  101.  
  102. }
  103.  
  104. function showAddress(address, zoom) {
  105. geocoder.geocode({'address': address}, function(results, status) {
  106. if (status == google.maps.GeocoderStatus.OK) {
  107. map.setCenter(results[0].geometry.location);
  108. map.setZoom(zoom);
  109.  
  110.  
  111. } else {
  112. alert("Geolokalizacja się nie udała, powód: " + status);
  113. }
  114. });
  115. }
  116.  
  117.  
  118. </script>
  119. {/literal}
[JAVASCRIPT] pobierz, plaintext


Ten post edytował qbas-s 26.02.2014, 14:15:36
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 16.10.2025 - 14:10