Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript] Google Maps API ikonka markera
ShamY
post 5.03.2014, 00:01:22
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
Mega_88
post 5.03.2014, 08:06:43
Post #2





Grupa: Zarejestrowani
Postów: 360
Pomógł: 34
Dołączył: 20.08.2011

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


Przykład drugi z tej strony dokładnie to czego szukasz: http://gmapsapi.com/poradnik/102_zmiana_do..._znacznika.html

Google --> google maps ikony markery
Go to the top of the page
+Quote Post
werdan
post 5.03.2014, 08:12:37
Post #3





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
ShamY
post 5.03.2014, 13:17:07
Post #4





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

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


@Mega_88: znalazłem tą stronę jednak tam jest pokazane jak dodac ikone do markera, ale bez dymku, a nie dałemr ady tego połączyć, bo twedy mapa się cała wyłączała.
@werdan: dzięki za kod, jednak jak dodać dany marker do wpisu? Bo po dodaniu tego kodu i ścieżki do obrazka markera na mapie zrobiło się pusto.

Ten post edytował ShamY 5.03.2014, 13:18:22
Go to the top of the page
+Quote Post
Damonsson
post 5.03.2014, 14:05:14
Post #5





Grupa: Zarejestrowani
Postów: 2 355
Pomógł: 533
Dołączył: 15.01.2010
Skąd: Bydgoszcz

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


[JAVASCRIPT] pobierz, plaintext
  1. marker1.setIcon('URL');
[JAVASCRIPT] pobierz, plaintext
Go to the top of the page
+Quote Post
ShamY
post 5.03.2014, 14:32:09
Post #6





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

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


Po wstawieniu tego mapa się niestety nie wyświetla w ogóle...
Go to the top of the page
+Quote Post
Damonsson
post 5.03.2014, 23:05:53
Post #7





Grupa: Zarejestrowani
Postów: 2 355
Pomógł: 533
Dołączył: 15.01.2010
Skąd: Bydgoszcz

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


Popatrz pan, a u mnie działa:

http://jsfiddle.net/Zuds3/131/
Go to the top of the page
+Quote Post
ShamY
post 5.03.2014, 23:24:20
Post #8





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

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


No ale u mnie nie działa...
  1. <script src='http://maps.google.com/maps?file=apiv=2&key=ABQIAAAALlcB2mNKHO3S7jhbuQncYhRO1J72BGfqxiUXRWzAvEIWI9ws6hQCOE0J_2PMfScH
    Kbedstjt8J94Hw'
    type='text/javascript'></script>
  2. </head>

  1. var marker1 = dodajMarker2(51.817105,18.688889,'<div class="dymek"><h4>Tytul</h4><p>Opis</div>');
  2. var marker1 = dodajMarker2(52.327786,20.998764,'<div class="dymek"><h4>Tytul2</h4><p>Opis2</div>');
  3. var marker1 = dodajMarker2(52.711807,16.377425,'<div class="dymek"><h4>Tytul3</h4><p>Opis3</div>');
  4.  
  5. marker1.setIcon('URL');


btw. tego głupkowatego mema "jestem idiotą" mógłbys sobie darować

Ten post edytował ShamY 5.03.2014, 23:26:25
Go to the top of the page
+Quote Post
Damonsson
post 5.03.2014, 23:34:22
Post #9





Grupa: Zarejestrowani
Postów: 2 355
Pomógł: 533
Dołączył: 15.01.2010
Skąd: Bydgoszcz

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


Przecież nie działa. Nie wiem o czym mówisz, jaki mem? ohmy.gif

Masz, cała noc przed Tobą, studiuj:
https://developers.google.com/maps/documentation/javascript/

+ Temat: JavaScript jesli Twoj watek go dotyczy KONIECZNIE przeczytaj

Ten post edytował Damonsson 5.03.2014, 23:35:17
Go to the top of the page
+Quote Post
werdan
post 6.03.2014, 08:36:45
Post #10





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

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


My piszemy o Google Maps API 3, ty używasz wersji 2 biggrin.gif
Go to the top of the page
+Quote Post
ShamY
post 6.03.2014, 13:21:27
Post #11





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

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


Cytat(werdan @ 6.03.2014, 08:36:45 ) *
My piszemy o Google Maps API 3, ty używasz wersji 2 biggrin.gif

Geniusz! smile.gif Nie mówie tego złośliwie, leci pomógł, do Damonsson również.

btw. TEN mem: http://jsfiddle.net/Zuds3/131/
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 26.04.2024 - 15:00