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

拟墨画扇 提交于 2019-12-11 18:09:38

问题


Currently we are using HERE Javascript Api 2.5.3 (https://js.api.here.com/se/2.5.3/jsl.js?with=all) and created a InfoBubbleMarker - within custom html content - based on the description in nokias developers ApiExplorer (http://developer.here.com/apiexplorer/examples/api-for-js/information-bubbles/extend-marker-to-infobubblemarker.html)

While the infoBubbles automated position switch - depending on the fact, where is place to display it - is often kind of nice, we want to disable it.

So: Is there any property to fix the position of the infoBubble?

Thanks in advance.


回答1:


You can use the defaultXAlignment and defaultYAlignment properties to alter the preferred offset for the Infobubble e.g.:

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

This still doesn't fix the position of the Infobubble though, since it will still switch to the other side if there is insufficient space on the right side of the map to display the bubble.

To completely fix the position of the Infobubble, you will also need to add observers to defaultXAlignment and defaultYAlignmentto ensure the value never changes:

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


来源:https://stackoverflow.com/questions/20515944/nokia-here-maps-javascript-api-is-there-any-property-to-fix-the-position-of-an

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!