0
如何讓顯示的地圖居中位置略低於位置的中心?Google Maps API和顯示位置
我在找的是我的信息窗口在頂部被切斷。
下面的代碼:
if(jQuery("#map").length)
{
geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': 'andrade motor car 975 Campbell Avenue West Haven, CT 06516' }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var loc = results[0].geometry.location;
var mapOptions = {
zoom: 17,
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: false,
mapTypeControl: false
};
map = new google.maps.Map(document.getElementById('map'), mapOptions);
map.setCenter(loc);
var marker = new google.maps.Marker({
position: results[0].geometry.location,
map: map//,
//icon: new google.maps.MarkerImage("/assets/images/map_pointer.png", new google.maps.Size(38, 45), null, new google.maps.Point(18, 44))
});
infobox = new google.maps.InfoWindow({
maxWidth: 400,
content: '<div style="width:300px !important;overflow:hidden !important;"><h2 class="shop-title">andrade motor car</h2><p>975 Campbell Avenue<br />West Haven, CT 06516<br />203-931-7575</div>'
});
infobox.open(map, marker);
map.panTo(new google.maps.LatLng(loc.lat(), loc.lng()));
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
我最初以爲通過做這樣的事情:
map.panTo(new google.maps.LatLng(loc.lat() - 1, loc.lng()));
可以做的伎倆,但它並沒有區別
您是否嘗試更改infoWindow的'pixelOffset'偏移量? –
我剛纔做了。想要發佈這個答案,我可以授予它。有效 :) – Kevin