在弹出窗口中重新加载谷歌地图API

时间:2012-10-09 11:18:06

标签: google-maps

我有一个弹出窗口的问题,我在谷歌地图中加载,但是当我点击第二个请求时,尽管我使用google.maps.event.trigger(地图,'调整大小),谷歌地图仍然没有刷新“); 我的代码是:

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");
   }
 });  
  }

HTML是:

<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>

然后地图不在标记的中心,标记在左上角。

0 个答案:

没有答案