javascript - google map api with street view in infowindow not working -
javascript - google map api with street view in infowindow not working -
in link on bottom set google map, have problem because when i'm clicking on marker, take me lastly info localization string.
http://bit.ly/1tyvidz
can help me ?
you need 1 var infowindow. should not declared within for(). notice: there can 1 id="content" (id unique).
here how think it:
when client clicks on marker, temporarily store marker var currentmarker; open infowindow. triggers infowindow.domready .
when dom of infowindow ready, create new var pano, , give position of currentmarker (both position of window & coordinates of panoramic view).
(notice other scripters: requires 'marker.png' in same folder index.php) code:
<!doctype html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> <title>complex icons</title> <style> html, body, #map-canvas { height: 100%; margin: 0px; padding: 0px } </style> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script> <script> var locationdata = [ [53.13449, 18.04292, "1. ul. gajowa 99, 85-700 bydgoszcz" ], [53.03783, 18.61368, "2. ul. polna 17, 87-100 torun"], [54.37890, 18.59159, "3. ul. partyzantów 70, 80-952 gdansk" ], [50.23122, 18.99280, "4. ul. rolna 7, 40-555 katowice" ], [50.06358, 19.97002, "5. ul. cystersów 21, 31-553 krakow" ], [50.01563, 21.97702, "6. ul. matuszczaka 5, 35-083 rzeszów" ], [51.20651, 22.58249, "7. ul. sierpinskiego 26, 20-448 lublin" ], [53.78115, 20.50410, "8. ul. towarowa 4, 10-417 olsztyn" ], [53.40699, 14.59046, "9. ul.gdanska 15a, 70-661 szczecin" ], [54.18990, 16.15861, "10. ul. bohaterów w-wy 3, 75-211 koszalin" ], [52.22472, 20.93692, "11. ul. sowinskiego 28, 01-105 warszawa" ] ]; function initialize() { var map = new google.maps.map(document.getelementbyid('map-canvas')); var contentstring = '<div id="content" style="width:300px;height:300px;"></div>'; var bounds = new google.maps.latlngbounds(); var currentmarker = null; var infowindow = new google.maps.infowindow({ content: contentstring }); google.maps.event.addlistener(infowindow, 'domready', function() { var pano = new google.maps.streetviewpanorama(document.getelementbyid("content"), { navigationcontrol: true, navigationcontroloptions: {style: google.maps.navigationcontrolstyle.android}, enableclosebutton: false, addresscontrol: false, linkscontrol: true }); // set position of infowindow (the div points marker) infowindow.setposition(currentmarker.getposition()); // set position of panoramic view right coordinates pano.setposition(currentmarker.getposition()); pano.setvisible(true); }); (var in locationdata) { var p = locationdata[i]; var latlng = new google.maps.latlng(p[0], p[1]); bounds.extend(latlng); var marker = new google.maps.marker({ position: latlng, map: map, title: p[2], icon: 'marker.png' }); google.maps.event.addlistener(marker, 'click', function() { currentmarker = this; // store marker clicked upon infowindow.open(map, this); }); } map.fitbounds(bounds); } google.maps.event.adddomlistener(window, 'load', initialize); </script> </head> <body> <div id="map-canvas"></div> </body> </html>
javascript
Comments
Post a Comment