Reputation: 2184
I'm drawing polygons in the UWP MapControl in Win 10. I saw you can change the appearance of map elements by generating a custom style sheet then assigning styles to elements. I found the Map Style Sheet Editor and created a new style sheet with extension styles:
{
"version": "1.*",
"settings": {
},
"elements": {
},
"extensions": {
"sxMapView": {
"polyRemoveArea": {
"fillColor": "#80FF0000",
"strokeColor": "#FFFF0000",
"strokeWidthScale": 5,
"visible": true
},
"polyProcessArea": {
"strokeColor": "#FF00FFFF",
"strokeWidthScale": 5,
"visible": true
},
"ptRemoveArea": {
"visible": true
},
"ptProcessArea": {
"visible": true
}
}
}
}
If I follow this example and assign "sxMapView.polyRemoveArea" in 2D map view everything works fine.
However if I switch to 3D map view with:
myMapControl.Style = MapStyle.Aerial3D;
The style seems to get ignored and a default of blue is used (I tested this by not applying a style to the polygon and it was filled with blue).
Also if you try and set the map to 3D before assigning the custom style sheet the custom style sheet reverts the map back to 2D view even though there's no styles describing that.
myMapControl.Style = MapStyle.Aerial3D; // <- Set map to 3D
string styleSheetJson = "{...json style sheet from above ...}"
...
myMapControl.StyleSheet = MapStyleSheet.ParseFromJson(styleSheetJson); // <- Map reverts to 2D
How do I define extension styles for map elements in the maps control style sheet and use the Aerial3D view?
Upvotes: 0
Views: 157
Reputation: 1772
You need to use the Combine method to add your style to an existing style like Aerial3D. Setting the style will completely reset anything you previously set which is why your JSON is overriding the set call for Aerial3D.
The sample code in MapStyleSheetEditor should show you how to do this (the little i button)
myMap.StyleSheet = MapStyleSheet.Combine(new List<MapStyleSheet>
{
MapStyleSheet.AerialWithOverlay(),
MapStyleSheet.ParseFromJson(jsonText)
});
Upvotes: 0