更改Google地图标记/ infowindow位置

时间:2012-09-08 12:08:20

标签: google-maps

我目前正在使用此代码段在某个页面上显示我的地图

<div id="map_canvas" style="width: 400px; height: 300px;"></div>
<div class="map_js">
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script>
var myLatlng = new google.maps.LatLng(0, 0);
var mapOptions = {
  zoom: 15,
  center: myLatlng,
  scrollwheel: true,
  scaleControl: false,
  disableDefaultUI: false,
  mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
var geocoder_map = new google.maps.Geocoder();
var address = 'New York';
geocoder_map.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: map.getCenter()
    });
    var contentString = 'Hello World New York is the most populous city in the United States.';
    var infowindow = new google.maps.InfoWindow({
      content: contentString,
      maxWidth: 200
    });
    google.maps.event.addListener(marker, 'click', function () {
      infowindow.open(map, marker)
    });
    infowindow.open(map, marker)
  } else {
    alert('Geocode was not successful for the following reason: ' + status)
  }
});
</script>
</div>

但是,正如您在此图像http://d.pr/i/whoI中所看到的那样,infowindow在某种程度上与默认地图UI重叠。

有人知道如何解决这个问题吗?

最诚挚的问候,Jen

0 个答案:

没有答案