Get the actual width and height of a point feature in OpenLayers

179 Views Asked by At

I am trying to figure out a way to get actual width and height of point feature. I.e., the image + text and not just the latitude / longitude of the geometry.

So far, I learnt that I could get coordinates by using the following code:

feature.getGeometry().getCoordinates();

But this gives me the exact coordinate where the feature was added but what I want is the width and height of the feature after it has been rendered. I.e., height = height of image + height of the label.

I am doing this to start wrapping texts when two feature are very closes to each other.

1

There are 1 best solutions below

0
Razvan Florea On

to get the height and width of an icon of a point in openlayers you can use:

feature.getStyle().getImage().getScale()
feature.getStyle().getText().getScale()

I must mention the fact that if you have not specified scales for the text and for the icon in the style, you will receive undefined