How to display a custom background instead of a fill color for shapes in Blazor Maps?
The Blazor Maps allow us to change the color of the geometry shape maps. You can also use an SVG pattern as a color for the shapes. This section will show you how to display an SVG pattern for the shapes in a custom map layer rendered in Maps.
To create your desired pattern, define an SVG pattern element in the razor page. To display the pattern style on the map layer’s custom shapes, set the id attribute of the SVG pattern element to the Fill property of the MapsShapeSettings of the MapsLayer.
The code example below shows how to display a custom background using an SVG pattern instead of a fill color for a custom shape map in Blazor Maps.
Index.razor
@using Syncfusion.Blazor.Maps
<svg>
<defs xmlns="http://www.w3.org/2000/svg"><pattern id="lines" patternUnits="userSpaceOnUse" width="2" height="5" patternTransform="rotate(60)"><line x1="0" y="0" x2="0" y2="11" stroke="#194d33" stroke-width="2" /></pattern></defs>
</svg>
<SfMaps ID="Maps">
<MapsZoomSettings Enable="true" ZoomFactor="4" MaxZoom="20"></MapsZoomSettings>
<MapsCenterPosition Latitude="40.724546" Longitude="-73.850344"></MapsCenterPosition>
<MapsLayers>
<MapsLayer UrlTemplate=https://tile.openstreetmap.org/level/tileX/tileY.png TValue="string">
</MapsLayer>
<MapsLayer Type="Syncfusion.Blazor.Maps.Type.SubLayer" ShapeData='new {dataOptions= "simplegeo.json"}' TValue="string">
<MapsShapeSettings Fill="url(#lines)">
<MapsShapeBorder Color="Red" Width="5"></MapsShapeBorder>
</MapsShapeSettings>
</MapsLayer>
</MapsLayers>
</SfMaps>
The following screenshot illustrates the output of the above code snippet.
Conclusion
I hope you enjoyed learning how to display a custom background instead of a fill color for shapes in the Blazor Maps Component.
You can refer to our Blazor Maps feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Blazor Maps example to understand how to create and visualize data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!