Will there be an example for the military symbolistaion?
ISchwarz23 opened this issue ยท 4 comments
Hi there,
I'm very interested in the new API regarding the military symbologies. Is it very different from the one in ArcGis Runtime? Will there be an example added to this repository?
Best regards,
Ingo
Hello Ingo,
Yes, it is quite different. In previous releases, while well designed and extremely productive, it didn't align with how all other rendering worked with the API. It had a "specialized" usage, so to speak. The new design is much better and integrated, in that it's more seamless and in-line with the common programming models for rendering symbology.
Yes, we are working hard to get a Java example published, so keep an eye out for it...
In the mean time, I find the API reference for DictionaryRenderer quite helpful,
https://developers.arcgis.com/java/beta/api-reference//reference/com/esri/arcgisruntime/symbology/DictionaryRenderer.html
We've got a few samples planned which show you how to use the dictionary renderer. The great thing about the new dictionary renderer is that you can apply it to either a graphics layer or a feature layer.
The 10.2.4 release could only display the symbols in a graphics layer.
Samples should be there in the next week to two. We'll link them to this issue once they are there.
To get you going I've added a little snippet of code which shows how to:
- create a symbol dictionary
- query it to get the symbols you want
- draw the symbols in a graphics overlay.
private void drawSymbols() {
// make a graphics overlay and add it to the map
System.out.println("started draw");
GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
mapView.getGraphicsOverlays().add(graphicsOverlay);
// create the dictionary renderer. This uses the mil2525d.stylx file in /resources/symbols/mil2525d directory
SymbolDictionary symbolDictionary = new SymbolDictionary("mil2525d");
symbolDictionary.loadAsync();
// listen for load status changes
symbolDictionary.addLoadStatusChangedListener(e -> {
// was the load status success?
System.out.println("changed status - " + symbolDictionary.getLoadStatus().toString());
if (e.getNewLoadStatus() == LoadStatus.LOADED) {
System.out.println("dictionary ready to use");
// perform a search of the dictionary
StyleSymbolSearchParameters params = new StyleSymbolSearchParameters();
params.getNames().add("Fires Points : Survey Control Point : ");
params.setNamesStrictMatch(false);
ListenableFuture<List<StyleSymbolSearchResult>> symbols = symbolDictionary.searchSymbolsAsync(params);
List<StyleSymbolSearchResult> symbolsResult;
double x = 0;
try {
// might be better not to block the UI tread, but just to show it working.
// get the symbols we've queried
symbolsResult = symbols.get();
// loop through the symbol results
for (StyleSymbolSearchResult symbolResult : symbolsResult) {
System.out.println("symbol - " + symbolResult.getName());
CimSymbol symbol = symbolResult.getSymbol();
System.out.println(symbol);
Point geometry = new Point(x, x, SpatialReference.create(4326));
x += 5;
// make a graphic with the geometry and CIM symbol and add it to the graphics overlay
Graphic gr = new Graphic(geometry, symbol);
graphicsOverlay.getGraphics().add(gr);
}
} catch (Exception e1) {
e1.printStackTrace();
}
}
});
}
@ISchwarz23 We merged in some samples today if you want to check them out.
Symbol Dictionary:
Dictionary Renderer with Graphics Overlay
- https://github.com/Esri/arcgis-runtime-samples-java/tree/master/display-information/dictionary-renderer-graphics-overlay
- https://github.com/Esri/arcgis-runtime-samples-java/tree/master/scene/dictionary-renderer-graphics-overlay-3D
Dictionary Renderer with Feature Layer