How to find geometry of TextSymbol

708
3
09-14-2017 01:43 PM
NavanJohnson
New Contributor II

I have some TextSymbols drawing on my map. I can listen to the 'mouse-over' event from layer.on and I get the events returning correctly. The problem I am having is that the event.graphic is a Point so the geometry and the extent is just a single point instead of the actual area of the text on the map. Is there some way to get the exact geometry of the TextSymbol instead of the Point?

3 Replies
ThomasSolow
Occasional Contributor III

You can't really describe the exact geometry of a text symbol in terms of map units as this number will change as you zoom in and out.  You could describe it in pixels.

In general, text symbols are set on point geometries.  So the user just describes the center of the text symbol and not the area it takes up.

NavanJohnson
New Contributor II

Yes, I get that the main geometry is a Point. However, no matter how I zoom the map in or out, edit the TextSymbol by making it smaller/larger, or even rotate it to any angle, the 'mouse-over' still fires exactly perfectly with the shape/size/orientation of the text. So it seems that the map must somehow be holding this exact geometry to be able to tell if your mouse pointer is inside it, right?

0 Kudos
ThomasSolow
Occasional Contributor III

I'm not completely sure how that stuff is implemented but when possible, I would guess it's better to do a pixel intersection check rather than a geometry intersection check, so that may be what gets done.

It is possible to generate a geometry based on a text symbol at a given zoom, but it might take some work and there's probably a better way to approach this.

0 Kudos