Select to view content in your preferred language

Labeling of features added via MessageProcessor (chemlight)

1675
4
Jump to solution
01-16-2013 06:03 AM
StefanP__Jung
Deactivated User
Currently i am working with the Vehicle Commander Template and i want to set a label for incoming chemlight messages.

I found out that the MessageProcessor uses the message property "UniqueDesignation" to label a trackrep message. But for a chemlight message using this property does not work. Cause the MessageProcessor itself is just a blackbox, i don't know if it is even possible.

Within the afmchemlight.json configuration file i also saw the 2 properties defaultLabel and label, so i expected that labeling should somehow be possible, or that labeling is even planned for the chemlight messages.

Is there any further documentation how to get it work?

A workaround would be to draw the chemlight in an own graphic layer and define a labeling, but it would be nice if the message processor could also handle this.

Stefan
0 Kudos
1 Solution

Accepted Solutions
MarkBaird
Esri Regular Contributor
Internally the API renders Chem Lights using a unique value renderer.  Therefore this does not support labels out of the box.

The other symbols for 2525C use a DictionaryRenderer which as you point out accept a Unique Designation which is your labelling item.

If you want to have a label for a Chem Light, then you will need to render your own using a TextMarker in a graphics layer.  The following code shows how this can be done.

        //graphics layer for labels
        GraphicsLayer labelsGL = new GraphicsLayer();
        map.getLayers().add(labelsGL);
       
        //Make a graphic for the label
        TextSymbol labelSymb = new TextSymbol(12, "ABC", Color.blue);
        Point labelLocation = new Point(2191602.87,626172.13);
        Graphic labelGraphic = new Graphic(labelLocation, labelSymb);
       
        //add graphic to the graphics layer
        labelsGL.addGraphic(labelGraphic);

You will of course need to consider how you place your labels.  The location of the point may need to change slightly according to the zoom level of the map if your label is offset from the location of the chem light.

So in conclusion it's possible,but it might involve a little more work than expected.

View solution in original post

0 Kudos
4 Replies
MarkBaird
Esri Regular Contributor
Internally the API renders Chem Lights using a unique value renderer.  Therefore this does not support labels out of the box.

The other symbols for 2525C use a DictionaryRenderer which as you point out accept a Unique Designation which is your labelling item.

If you want to have a label for a Chem Light, then you will need to render your own using a TextMarker in a graphics layer.  The following code shows how this can be done.

        //graphics layer for labels
        GraphicsLayer labelsGL = new GraphicsLayer();
        map.getLayers().add(labelsGL);
       
        //Make a graphic for the label
        TextSymbol labelSymb = new TextSymbol(12, "ABC", Color.blue);
        Point labelLocation = new Point(2191602.87,626172.13);
        Graphic labelGraphic = new Graphic(labelLocation, labelSymb);
       
        //add graphic to the graphics layer
        labelsGL.addGraphic(labelGraphic);

You will of course need to consider how you place your labels.  The location of the point may need to change slightly according to the zoom level of the map if your label is offset from the location of the chem light.

So in conclusion it's possible,but it might involve a little more work than expected.
0 Kudos
StefanP__Jung
Deactivated User
Hi Mark,

thank you for the quick response. And good to know how it works under the hood.

So I will use your approache and label the chemlights in a separat graphics layer if the message processor successfully proccessed the message and the type is chemlight.

I've tested it quick & dirty - and it works like expected.

But with a TextSymbol I am not able to define a halo like the message processor does for labeling. I can only define the size and color, not even if it should be bold? I also used the Json syntax to set some more prameters (equald to JS API), but it looks like this parameters will be ignored.

Stefan
0 Kudos
MarkBaird
Esri Regular Contributor
Hi Stefan,

If you switch to using the new release 10.1.1 we have implemented a new selection capability for graphics which I think does what you are after.  When you select a graphic it adds a halo around it.

So adding to the code we looked at yesterday to create a text symbol, you can select a graphic (which adds a halo) like this:

        //select the highlight color (if you don't it defaults to cyan)
        labelsGL.setSelectionColor(Color.green);
       
        //select the graphic so it has a halo
        labelsGL.select(labelID);

[ATTACH=CONFIG]20829[/ATTACH]

Hope that helps

Mark
0 Kudos
StefanP__Jung
Deactivated User
Hi Mark,

i will test this when i've downloaded the new Java SDK. This morning i saw the post that it has been released. But the download was not yet available in the customer care. I am looking forward to see more features in the Runtime which are already available in the web apis 😄

Thanks a lot for your help.

Stefan

Edit: I've just tested the selection and this solution will work for me. thanks.
0 Kudos