诺基亚HERE Maps javascript API:是否有任何属性可以修复infoBubble的位置?

时间:2013-12-11 09:56:51

标签: javascript maps here-api

目前我们正在使用 HERE Javascript Api 2.5.3(https://js.api.here.com/se/2.5.3/jsl.js?with=all)并在自定义html内容中创建InfoBubbleMarker - 基于nokias开发人员ApiExplorer中的描述( http://developer.here.com/apiexplorer/examples/api-for-js/information-bubbles/extend-marker-to-infobubblemarker.html

虽然infoBubbles自动位置切换 - 取决于事实,显示它的位置 - 通常很好,我们想要禁用它。

那么property的{​​{1}}是fixposition吗?

提前致谢。

1 个答案:

答案 0 :(得分:0)

您可以使用defaultXAlignmentdefaultYAlignment属性来更改Infobubble的首选偏移量,例如:

var infoBubbles = new nokia.maps.map.component.InfoBubbles();
infoBubbles.options.set("defaultXAlignment", 
    nokia.maps.map.component.InfoBubbles.ALIGNMENT_RIGHT);
infoBubbles.options.set("defaultYAlignment",
     nokia.maps.map.component.InfoBubbles.ALIGNMENT_ABOVE);
map.components.add(infoBubbles);

这仍然不会修复 Infobubble的位置,因为如果地图右侧没有足够的空间显示,它仍将切换到另一侧泡沫。

完全修复 Infobubble的位置,您还需要向defaultXAlignmentdefaultYAlignment添加观察者,以确保价值永不改变:< / p>

infoBubbles.addObserver("defaultXAlignment", function (){
    this.set("defaultXAlignment",
        nokia.maps.map.component.InfoBubbles.ALIGNMENT_RIGHT);});
 infoBubbles.addObserver("defaultYAlignment", function (){
    this.set("defaultYAlignment",
        nokia.maps.map.component.InfoBubbles.ALIGNMENT_ABOVE);});