I'm using OpenLayers for a school project.
In my map, I load GeoJSON
Point features as a VectorLayer
on top of a base mapbox
layer. The points represent buildings. When the points are clicked, an ol.Overlay
tooltip is shown containing the name of the building.
When the tooltip is generated in the center of the screen, it looks great:
When I drag the map such that the point goes close to the right edge of the screen, the tooltip prevents the contents from overflowing, which is really neat:
However when I try to do the same for the left edge of the screen, I don't get this behaviour, and instead the tooltip contents simply overflow:
Suppose the user were to click on a point that was close to the left edge of the screen. If the name of the building was long, the tooltip will be generated with half of it spilling out of the left edge of the screen, which is a little jarring.
May I know what properties I should set under ol.Overlay
to fix this problem?
Thanks!
EDIT 1: Here is a JSFiddle that shows the behaviour. Try dragging the map such that the tooltip is near the right and left of the screen. https://jsfiddle.net/meeps/kosx7w9d/4/