Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript] Google Maps API ikonka markera
ShamY
post
Post #1





Grupa: Zarejestrowani
Postów: 111
Pomógł: 0
Dołączył: 11.07.2013

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


Witam,
mam kod:

  1. <script type="text/javascript">
  2.  
  3. var mapa;
  4. var dymek = new google.maps.InfoWindow(); // zmienna globalna
  5.  
  6. function dodajMarker(lat,lng,txt)
  7. {
  8. // tworzymy marker
  9. var opcjeMarkera =
  10. {
  11. position: new google.maps.LatLng(lat,lng),
  12. map: mapa
  13. }
  14. var marker = new google.maps.Marker(opcjeMarkera);
  15. marker.txt=txt;
  16.  
  17. google.maps.event.addListener(marker,"click",function()
  18. {
  19. dymek.setContent(marker.txt);
  20. dymek.open(mapa,marker);
  21. });
  22. return marker;
  23. }
  24.  
  25. function mapaStart()
  26. {
  27. var wspolrzedne = new google.maps.LatLng(52.068876,19.479654);
  28. var opcjeMapy = {
  29. zoom: 7,
  30. center: wspolrzedne,
  31. mapTypeId: google.maps.MapTypeId.ROADMAP
  32. };
  33.  
  34. mapa = new google.maps.Map(document.getElementById("mapka"), opcjeMapy);
  35. var marker1 = dodajMarker(52.068876,19.479654,'1');
  36. var marker2 = dodajMarker(52.227799,20.960083,'2');
  37. var marker3 = dodajMarker(52.449314,16.884155,'3');
  38. google.maps.event.trigger(marker1,'click');
  39. }
  40. </script>


moim pytaniem jest, jak zmienić ikonkę danego markera

Wie ktos jak to zrobić?

Ten post edytował ShamY 5.03.2014, 00:10:09
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
werdan
post
Post #2





Grupa: Zarejestrowani
Postów: 354
Pomógł: 100
Dołączył: 14.11.2013
Skąd: Płock

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


  1. var image = new google.maps.MarkerImage(
  2. '/images/gm-marker.png',
  3. new google.maps.Size(27, 35),
  4. new google.maps.Point(0, 0),
  5. new google.maps.Point(14, 35)
  6. );
  7.  
  8. var shadow = new google.maps.MarkerImage(
  9. '/images/gm-marker-shadow.png',
  10. new google.maps.Size(49, 35),
  11. new google.maps.Point(0, 0),
  12. new google.maps.Point(14, 35)
  13. );
  14.  
  15. var MarkerOptions = {
  16. position: coords,
  17. icon: image,
  18. shadow: shadow,
  19. map: map
  20. };
  21. var marker = new google.maps.Marker(MarkerOptions);



coś takiego
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: 7.10.2025 - 02:23