Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Google Maps API v3] Opisy markerów w MarkerClusterer, Problem z dodaniem chmurek do markerów grupowanych MarkerClusterer
czaj
post
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 22.11.2012

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


Witam

Mam problem jak w temacie.
Tworzę na swojej stronie mapę z Google Maps API v3. Do dodawania markerów używam funkcji:

  1. function dodajMarker(wspolrzedne,idPunktu) {
  2. var marker = new google.maps.Marker({
  3. position: wspolrzedne,
  4. map: mapa,
  5. }); // dodanie markera
  6. var infowindow = new google.maps.InfoWindow();
  7. google.maps.event.addListener(marker, 'click', function() {
  8. var markerContent = '<div class="infoWindow">Bla Bla</div>';
  9. infowindow.setContent(markerContent);
  10. infowindow.setZIndex(1);
  11. infowindow.open(mapa,marker);
  12. }); //dodanie do markera chmurki
  13. }


Tutaj wszystko działa pięknie, ale jak chcę użyć opcji MarkerClusterer ( http://google-maps-utility-library-v3.goog...le_example.html ) to już nie jest tak kolorowo.

Tworzę kod:

  1. var wspolrzedneArray = [];
  2. var idPunktuArray = [];
  3. var ArrayMarkerClusterer = [];
  4.  
  5. function dodajMarkerTest(wspolrzedneArray,idPunktuArray) {
  6. for (x = 0; x < wspolrzedneArray.length; x++){
  7. var latLng = wspolrzedneArray[x]
  8. var marker = new google.maps.Marker({
  9. position: latLng,
  10. map: mapa,
  11. });
  12. ArrayMarkerClusterer.push(marker);
  13. }
  14. var mcOptions = {gridSize: 50, maxZoom: 10};
  15. var markerCluster = new MarkerClusterer(mapa, ArrayMarkerClusterer, mcOptions);
  16. }


No i tutaj już "za Chiny" nie wiem jak dodać
  1. google.maps.event.addListener(marker, 'click', function());

żeby chmurki wyświetlały się prawidłowo. Pomoże ktoś(IMG:style_emoticons/default/questionmark.gif)

Ten post edytował czaj 22.11.2012, 12:35:53
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
czaj
post
Post #2





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 22.11.2012

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


Też nic.
Napisałem taką funkcję:

[JAVASCRIPT] pobierz, plaintext
  1.  
  2. var markerWspolrzedne = [];
  3. var markerID = [];
  4. var ArrayMarkerClusterer = [];
  5.  
  6. function dodajMarkerTest(markerWspolrzedne,markerID) {
  7. for (x = 0; x < markerWspolrzedne.length; x++){
  8. var latLng = markerWspolrzedne[x]
  9. var marker = new google.maps.Marker({
  10. position: latLng,
  11. map: mapa,
  12. icon: 'img/punkty/point_2.png',
  13. title: 'Click to see the charging point',
  14. });
  15. ArrayMarkerClusterer.push(marker);
  16.  
  17. var infowindow = new google.maps.InfoWindow();
  18. google.maps.event.addListener(marker,'click', function () {
  19. alert('click marker');
  20. var markerContent = '<div class="infoWindow" id="idPunktu-'+x+'"></div>';
  21. infowindow.setContent(markerContent);
  22. infowindow.setZIndex(1);
  23. infowindow.open(mapa,marker);
  24. //getValuePoint(idPunktu); // --- odwolanie do funkcji ladujacej tresc okienka
  25. })
  26. }
  27.  
  28. var mcOptions = {gridSize: 50, maxZoom: 10};
  29. var markerCluster = new MarkerClusterer(mapa, ArrayMarkerClusterer, mcOptions);
  30.  
  31. google.maps.event.addListener(markerCluster, 'clusterclick', function(cluster) {
  32. alert('click') // test czy dziala
  33. cluster.getCenter(wspolrzedne); // LatLng - srodek klastra
  34. cluster.getMarkers(ArrayMarkerClusterer); // Tablica markerów, które zostaly objete przez klaster
  35. cluster.getSize(x); // Rozmiar - chyba liczba markerów
  36. console.log(cluster);
  37. });
  38. };
  39.  
[JAVASCRIPT] pobierz, plaintext


Efekt jest taki że chmurka się włącza ale nie jest przypisana do markera którego się klika, tylko do pierwszego/ostatniego załadowanego markera, niezależnie który marker się kliknie

Ten post edytował czaj 22.11.2012, 22:16:02
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 - 20:31