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

Nokia HERE Maps javascript API: Is there any property to fix the position of an infoBubble?

本文关键字:infoBubble 位置 属性 任何 javascript 地图 HERE API 是否 诺基亚      更新时间:2024-06-27

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

虽然infoBubbles自动位置开关——取决于实际情况,在哪里显示它——通常有点不错,但我们想禁用它

那么:有没有propertyfix——infoBubbleposition

提前谢谢。

您可以使用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添加观察员,以确保值永远不会更改:

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);});