Pri Santos
Pri Santos

Reputation: 409

Write text in OpenLayers3

I need to write some text in openLayers 3... Not a label, something like a text object, that I can select and drag around the map. This text must have multiple lines. I tried to use a point with ol.style.text, but it isn't multiline. I also tried the popups, but I need the text to be always displayed. Is there any way to use a text feature for this (ol.format.TextFeature)? Is there any object that I can use for that purpose? Thanks!!

Upvotes: 0

Views: 1009

Answers (1)

Alexandre Dubé
Alexandre Dubé

Reputation: 2829

You can use an ol.Overlay for that. An overlay is basically anything an Element can be. It has a position an positioning that can be set at any time.

See an example: http://openlayers.org/en/v3.9.0/examples/overlay.html?q=overlay

You could use map browser events (pointerdown, pointerup) and if the target is your overlay element then you could move it around and update its position.

Upvotes: 1

Related Questions