Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [inne] Google Maps API
bahh
post 9.09.2013, 14:10:40
Post #1





Grupa: Zarejestrowani
Postów: 261
Pomógł: 2
Dołączył: 13.05.2012

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


Dzień dobry,

wtajemniczam się w Google Maps API. Wygenerowałem sobie kod na stronę:

  1. <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=TUTAJKODWYGENEROWANY&sensor=false" type="text/javascript"></script>
  2. <!-- <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=TUTAJKODWYGENEROWANY&sensor=false"></script> -->
  3. <script type="text/javascript">
  4. function initialize() {
  5. if (GBrowserIsCompatible()) {
  6. var map = new GMap2(document.getElementById("map_canvas"));
  7. var center = new GLatLng(30.276067, 12.570212);
  8. map.setCenter(center, 15);
  9. map.addControl(new GSmallMapControl());
  10. map.addControl(new GMapTypeControl());
  11.  
  12. var marker = new GMarker(center, {draggable: true});
  13.  
  14. GEvent.addListener(marker, "dragstart", function() {
  15. map.closeInfoWindow();
  16. });
  17.  
  18. GEvent.addListener(marker, "dragend", function() {
  19. marker.openInfoWindowHtml("Just bouncing along...");
  20. });
  21.  
  22. map.addOverlay(marker);
  23.  
  24. }
  25. }
  26. <div id="map_canvas" style="width: 990px; height: 400px"></div>


Mam oczywiście wygenerowany kod API dla strony na wybrane domeny na tej stronie (dałem adresy z www i bez) oraz włączyłem w services z maps v3 i maps v2. Niestety mapa nie chce się włączyć, wyświetlają się okna dla kodu js:
  1. <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=TUTAJKODWYGENEROWANY&sensor=false" type="text/javascript"></script>

Google has disabled use of the Maps API for this application. The provided key is not a valid Google API Key, or it is not authorized for the Google Maps Javascript API v2 on this site. If you are the owner of this application, you can learn about obtaining a valid key here: http://code.google.com/apis/maps/documenta...l#Obtaining_Key

  1. <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=TUTAJKODWYGENEROWANY&sensor=false"></script>

W Google wyłączono możliwość korzystania z interfejsu API Map Google w przypadku tej aplikacji. Podany klucz nie jest prawidłowym kluczem interfejsu API Google lub nie ma autoryzacji dla interfejsu API Javascript Map Google w wersji 3 w tej witrynie. Jeśli jesteś właścicielem tej aplikacji, informacje na temat uzyskiwania prawidłowego klucza możesz znaleźć tutaj: https://developers.google.com/maps/document...utorial#api_key

Wie ktoś co jest źle? Miał ktoś styczność z takim problemem?
Go to the top of the page
+Quote Post
Mega_88
post 9.09.2013, 20:17:05
Post #2





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

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


z V2 już się nie korzysta V3 wrzuć to na stronę:


  1. <div id="mapa-box" style="float:left;width:600px;height:300px;"></div>
  2. <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
  3. <script type="text/javascript">
  4. initialize();
  5. function initialize() {
  6. var myLatlng = new google.maps.LatLng(54.3911205821238, 18.66003618650825);
  7. var mapOptions = {
  8. zoom: 13,
  9. center: myLatlng,
  10. scrollwheel:false,
  11. mapTypeId: google.maps.MapTypeId.ROADMAP
  12. }
  13.  
  14. var map = new google.maps.Map(document.getElementById('mapa-box'), mapOptions);
  15.  
  16. var contentString = 'Nazwa<br />ulica<br />miasto<br/>co tam chcesz';
  17.  
  18. var infowindow = new google.maps.InfoWindow({
  19. content: contentString
  20. });
  21. var image = 'URL DO IKONY/ikona.png';
  22. var marker = new google.maps.Marker({
  23. position: myLatlng,
  24. map: map,
  25. icon: image,
  26. title: 'Tytuł'
  27. });
  28. google.maps.event.addListener(marker, 'click', function() {
  29. infowindow.open(map,marker);
  30. });
  31. }
  32.  
  33. google.maps.event.addDomListener(window, 'load', initialize);


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: 24.04.2024 - 07:51