The ExternalGraphic
element in a Symbology Encoding file declares its graphic either as a URL, or as a file path in an OnlineResource
tag, or as InlineContent
, using a base64-encoded image for example.
In LuciadRIA, you can also map the ExternalGraphic
elements to your own icon images.
To map them to other icon images, pass an IconProvider
to the SEPainterFactory
functions that parse the Symbology Encoding file.
For each ExternalGraphic
it encounters in the source file, LuciadRIA prompts the IconProvider
so that it can give a distinct icon image, URL, or file path.
This program shows an example implementation of an IconProvider
.
const iconProvider = {
getIcon(uri: string): HTMLImageElement | HTMLCanvasElement | string {
if (uri === "the_external_graphic_to_change") {
//provide a custom icon for the ExternalGraphic with above identifier
return "path/to/my/icon.png";
} else {
// Simply returning the input string will make RIA handle the ExternalGraphic as it normally would
return uri;
}
}
}
// Pass the iconProvider as an option to the SEPainterFactory method, then use the painter as usual
createPainterFromURL("style.xml", {iconProvider: iconProvider}).then(function(painter) {
map.layerTree.addChild(new FeatureLayer(model, {
painter: painter
}));
});