I'm building an interactive map. A feature that has been identified as important by the stakeholders is being able to add points and associate data with them. I'd like this to be very user-friendly in terms of editing or deleting points or the associated text. Basically, what I want is a way to directly associate a point and some arbitrary text.

Currently, I'm using a graphicsLayer for the points. I can use the graphicsLayer with TextSymbol to add text, but each individual graphic object can only one symbol (this means no point if I go with text, and vice-versa). Basically, my "solution" is to do the following:

var newPoint = new Graphic(event.geometry);
newPoint = new Graphic(event.geometry, myTextSymbol);

This isn't the end of the world, but it's not preferable. The point and it's associated string are separate entities so modifying one needs to be propagated to the other. Is there a build in feature to handle this? LabelLayer was my first guess, but it appears to only support FeatureLayers.


Short answer: No, the native ESRI JS API for representing a graphic permits only one symbol type at a time.

In my applications, I use the same compromised solutions as you.

You could look into extending the base Graphic class to add a second symbol or use a graphics packages like RaphaelJS to modify the symbol post-creation but of course that would not really be out of the box...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.