Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Google Maps API v3] ukrywanie markerów
warland
post
Post #1





Grupa: Zarejestrowani
Postów: 50
Pomógł: 0
Dołączył: 22.01.2018

Ostrzeżenie: (10%)
X----


Mam taki kod:

  1. var bounds = new google.maps.LatLngBounds();
  2. var i, center;
  3.  
  4. for (i = 0; i < shape.length; i++) {
  5. bounds.extend(shape[i]);
  6.  
  7. }
  8. center = bounds.getCenter();
  9. var image = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag2.png';
  10. var marker = new google.maps.Marker({
  11. position: { lat: center.lat() + land_size, lng: center.lng() },
  12. map: map,
  13. zIndex: 10,
  14. icon: image
  15. });
  16. google.maps.event.addListener(map, 'zoom_changed', function() {
  17. zoom = map.getZoom();
  18.  
  19. if (zoom < 7) {
  20. marker.setVisible(false);
  21. } else {
  22. marker.setVisible(true);
  23. }
  24. });
  25. marker.setVisible(false);



Problem polega na tym że w chwili odkrycia markerów ładuje się tylko jeden (mimo że np. jest ich 5)
Nie wiem jak ten problem rozwiązać.
Bez ukrywania markerów wszystko działa jak należy i pojawiają się wszystkie.

Czy jest ktoś kto może mi pomóc?

Ten post edytował warland 6.02.2018, 12:34:48
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
warland
post
Post #2





Grupa: Zarejestrowani
Postów: 50
Pomógł: 0
Dołączył: 22.01.2018

Ostrzeżenie: (10%)
X----


  1. var bounds = new google.maps.LatLngBounds();
  2. var i, center;
  3. var markers = [];
  4.  
  5. for (i = 0; i < shape.length; i++) {
  6.  
  7. center = bounds.getCenter();
  8. var image = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png';
  9. var marker = new google.maps.Marker({
  10. position: { lat: center.lat() + land_size, lng: center.lng() },
  11. map: map,
  12. zIndex: 10,
  13. icon: image
  14. });
  15. bounds.extend(shape[i]);
  16. markers.push(marker);
  17. }


przepraszam ale kompletnie nie potrafię tego ogarnąć. Wszystko na zasadzie każdej informacji z google sprawdzam by jakoś to wdrożyć. Zazwyczaj potrafię znaleźć rozwiązanie jak tylko ktoś mi coś podpowie gdzie szukać, ale tym razem każda próba zakończona porażką.
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: 12.10.2025 - 11:08