我试图实现一个自定义的infoBubble,它具有打开到标记侧面的框,而不是在顶部的默认位置。结果比预期的更难。谷歌地图InfoBubble pixelOffset(从标记默认位置移动)
使用正常的infoWindow可以使用pixelOffset。看到这里的documentation
使用infoBubble这似乎并非如此。无论如何在infoBubble中使用pixelOffset,还是会做同样的事情?
我发现这很难搜索,如使用谷歌搜索,例如它没有返回任何相关结果Google Search
下面是我所有的资源我一直在使用。
现在我的JavaScript只是在案件jsfiddle链接坏了。
<script type="text/javascript">
$(document).ready(function() {
init();
});
function init() {
//Setup the map
var googleMapOptions = {
center: new google.maps.LatLng(53.5167, -1.1333),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
//Start the map
var map = new google.maps.Map(document.getElementById("map_canvas"),
googleMapOptions);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(53.5267, -1.1333),
title: "Just a test"
});
marker.setMap(map);
infoBubble = new InfoBubble({
map: map,
content: '<div class="phoneytext">Some label</div>',
//position: new google.maps.LatLng(-35, 151),
shadowStyle: 1,
padding: '10px',
//backgroundColor: 'rgb(57,57,57)',
borderRadius: 5,
minWidth: 200,
arrowSize: 10,
borderWidth: 1,
borderColor: '#2c2c2c',
disableAutoPan: true,
hideCloseButton: false,
arrowPosition: 7,
backgroundClassName: 'phoney',
pixelOffset: new google.maps.Size(130, 120),
arrowStyle: 2
});
infoBubble.open(map, marker);
}
</script>
更新
为了帮助回答这个问题之前,我有一个测试用例这里放在一起
。重要的行是38行,它应该指定标签的位置。
更新2
对于奖金被授予我需要看到infoBubble的示例定位从标记高于其默认位置移开。优选地在标记的右侧。
更新3
我已删除了更新1的测试用例,因为它是在我的旧公司的服务器托管。
只是头脑风暴:如果您知道标记的位置:(LNG,LAT),然后(LNG + X,LAT)应该是泡的位置,正确的? – Gavriel
这听起来像它可以工作是的 – Undefined