For Map Add-on, JMIX Documentation provides method to set styles to geo-objects on a particular vector layer. As in GIS software, we wants to style each geo-object differently based on one of its property in a vector layer. We are using JMIX 1.5. Please guide. Thanks.
Hello!
You can do it the same way like in documentation example:
@Install(to = "map.territoryLayer", subject = "styleProvider")
private GeometryStyle mapTerritoryLayerStyleProvider(Territory territory) {
return geometryStyles.polygon()
.setFillColor("#08a343")
.setStrokeColor("#004912")
.setFillOpacity(0.3)
.setStrokeWeight(1);
}
The function above is applied for each geo-object that associated with Territory entity in a vector layer. So depending on Territory instance you can change fill color, stroke color, etc. For instance:
@Install(to = "map.territoryLayer", subject = "styleProvider")
private GeometryStyle mapTerritoryLayerStyleProvider(Territory territory) {
PolygonStyle polygonStyle = geometryStyles.polygon()
.setFillColor("#08a343")
.setStrokeColor("#004912")
.setFillOpacity(0.3)
.setStrokeWeight(1);
if (territory.getType() == "industrial") {
polygonStyle.setFillColor("#BF3030");
}
return polygonStyle;
}
1 Like
Thanks, Roman