admin管理员组文章数量:1399823
I want to know how I can position the infobox for the Google markers, not over the pin but something similar to this website. Here, when you hover over group of markers the infobox is shown at the same point thus the mouseout event is not triggered because the mouse is still over the group of markers.
I want to know how I can achieve something similar with the post I did yesterday. So to wrap up the post, is there any styling code which I can apply so I can show the infobox right over the marker?
I want to know how I can position the infobox for the Google markers, not over the pin but something similar to this website. Here, when you hover over group of markers the infobox is shown at the same point thus the mouseout event is not triggered because the mouse is still over the group of markers.
I want to know how I can achieve something similar with the post I did yesterday. So to wrap up the post, is there any styling code which I can apply so I can show the infobox right over the marker?
Share Improve this question edited Oct 9, 2022 at 19:31 halfer 20.4k19 gold badges109 silver badges202 bronze badges asked Nov 20, 2013 at 20:40 LazialeLaziale 8,23548 gold badges155 silver badges271 bronze badges2 Answers
Reset to default 5It is set at 140px in right by default, so set the values for x and y respectively and the box will appear there everytime.
offset values you can arrange yourself.
try this code..
var infowindows = []; //make it global
var popup = new InfoBox({
// size: new google.maps.Size(420,130),
content:content_info
,pixelOffset: new google.maps.Size(10, -100) //these are the offset values to be adjusted accordingly..
,disableAutoPan: false
,closeBoxMargin: "5px 5px 2px 2px"
,boxStyle: {opacity: 0.95
}
});
infowindows.push(popup);
google.maps.event.addListener(marker, 'mouseover', function() {
close_popups();
map.panTo(mycenter1);
popup.open(map, marker);
// currentPopup = null;
});
function close_popups(){
for(var i = 0; i<infowindows.length; i++){
infowindows[i].close();
}
}
You can use the alignBottom
and pixelOffset
properties of InfoBox
to achieve what you want. I created a fiddle which admittedly looks terrible, but I think it can get you on the right track in terms of the implementation. You can polish it to your liking after you get it working :) FIDDLE
Basically, you specify the options like:
var ibOptions = {
content: 'your content',
pixelOffset: new google.maps.Size(-5, -15),
alignBottom: true
};
You can adjust the pixelOffset to your liking, so the content shows over the marker and the mouseout is not triggered.
Then you do this to bind to the mouseover event (which you probably already know):
google.maps.event.addListener(marker, "mouseover", function (e) {
ib.open(map, this);
});
本文标签: javascriptGoogle Maps infobox position next to marker not over the markerStack Overflow
版权声明:本文标题:javascript - Google Maps infobox position next to marker not over the marker - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744224139a2596006.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论