Reload google map API in a popup
Hi all,
I've an issue with a popup, I load in a google map, but when I click for a second request , the google maps isn't refresh despite I use
google.maps.event.trigger(map, 'resize');
My code is :
- var geocoder;
- var map = null;
- function initialize() {
- geocoder = new google.maps.Geocoder();
- var latlng = new google.maps.LatLng(-34.397, 150.644);
- var mapOptions = {
- zoom: 12,
- center: latlng,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- }
- map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
- googlemaps();
-
-
- }
- function lafonction(){
- $( "#popupMap" ).popup( "open" );
-
- }
- function googlemaps(){
- var address = window.localStorage.getItem("url");
- geocoder = new google.maps.Geocoder();
- geocoder.geocode({ 'address': address }, function(results, status) {
- if (status == google.maps.GeocoderStatus.OK) {
- map.setCenter(results[0].geometry.location);
- var marker = new google.maps.Marker({
- map: map,
- position: results[0].geometry.location
- });
- google.maps.event.trigger(map, 'resize');
-
-
- } else {
- alert("Pas de localisation");
- }
- });
- }
the HTML is :
- <a href="#" data-rel="popup" data-position-to="window" data-role="button" data-theme="b" data-inline="true" onClick="lafonction()">Localiser</a>
- <div id="fiche" data-role="listview">
- <div data-role="popup" id="popupMap" data-overlay-theme="a" data-theme="a" data-corners="false" data-tolerance="15,15">
- <a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="delete" data-iconpos="notext" class="ui-btn-right">Close</a>
- <iframe src="map.html" width="480" height="320" seamless></iframe>
- </div>
- </div>
And then the map is not centerd on the marker, the marker is on the left corner.
thanks a lot