我正在开发一个谷歌地图项目。我们使用自定义叠加层作为弹出标记。弹出窗口应该很大。因此,我想在单击标记时平移地图,使标记距视口底部约 50 像素,以便为弹出窗口留出空间。
目前,我只是将其平移到标记的纬度/经度。
google.maps.event.addDomListener(div, "click", function(e) {
var x = e.x,
y = $(div).offset(),
windowHeight = $(window).height(),
windowWidth = $(window).width();
if(!$(div).find('.ryan').hasClass("scaleUp")){
map.panTo({lat: args.location.lat, lng: args.location.lng})
var top = $(div).offset().top, mapHeight = $('#content-wrapper').height();
$(div).append(buildBubble(self.getHcpCount())).css("z-index", markerZindex++)
var bubble = $(this).find('.ryan');
var windowPercentage = .5;
bubble.css({
"width": windowWidth * windowPercentage,
"height": windowHeight * windowPercentage,
"top": 0,
"left": 0,
"margin-top": -1 * windowWidth * windowPercentage / 2,
"margin-left": -1 * windowWidth * windowPercentage / 2 + $(this).width() / 2
});
bubble.find('.bubble-body').css({
"height": bubble.height() …
Run Code Online (Sandbox Code Playgroud)