Google地图会加载到标记的右侧!

时间:2011-03-16 01:54:08

标签: google-maps google-maps-api-3 google-maps-markers

出于某种原因,谷歌地图正在加载以下地图,左侧是标记 - 我不知道为什么。

我在iFrame中有这个页面,它被加载到灯箱中,但问题是它没有将地图正好加载到标记上,它总是在左边。

   <link href="https://code.google.com/apis/maps/documentation/javascript/examples/standard.css" rel="stylesheet" type="text/css" /> 
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script> 
<script type="text/javascript"> 
  var geocoder;
  var map;
  function initialize() {
    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(-0, 0);
    var myOptions = {
      zoom: 15,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  }

  function codeAddress() {
    var address = '1 Dover Street, London, United Kingdom';

    geocoder.geocode( { 'address': address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {

        var latlng = new google.maps.LatLng(results[0].geometry.location);
        var myOptions = {
            zoom: 15,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        }

        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);  
        map.setCenter(results[0].geometry.location);
        var marker = new google.maps.Marker({
            map: map, 
            position: results[0].geometry.location
        });
      } else {
        //alert("Geocode was not successful for the following reason: " + status);
      }
    });
  }
</script> 

如果有人能让我知道它为什么这样做,那就太棒了!

谢谢!

0 个答案:

没有答案