问题
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 defaultYAlignment
to 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