How to display different google Map layers such as the street Map, the Terrain, etc. in the .NET MAUI Maps?
In the Syncfusion® .NET MAUI Maps control, you can show different Google Map views by providing the corresponding URL to the UrlTemplate property of the MapTileLayer.
Add the SfMaps control in your layout and add Markers to the MapTileLayer, as shown in the following code sample.
XAML:
<map:SfMaps>
<map:SfMaps.Layer>
<map:MapTileLayer x:Name="layer">
<map:MapTileLayer.Markers>
<map:MapMarkerCollection>
<map:MapMarker Latitude="38.8833"
Longitude="-77.0167" />
<map:MapMarker Latitude="-15.7833"
Longitude="-47.8667" />
<map:MapMarker Latitude="21.0000"
Longitude="78.0000" />
<map:MapMarker Latitude="35.0000"
Longitude="103.0000" />
<map:MapMarker Latitude="-4.0383"
Longitude="21.7586" />
</map:MapMarkerCollection>
</map:MapTileLayer.Markers>
</map:MapTileLayer>
</map:SfMaps.Layer>
</map:SfMaps>
To load the Google Map view, assign the Google Maps URL link with required x, y, and lyrs parameters to the UrlTemplate property of the MapTileLayer.
C#:
this.layer.UrlTemplate = "https://mt0.google.com/vt/lyrs=m&x={x}&y={y}&z={z}";
You can get the different map views based on the value of lyrs as shown in the following table values:
Table:
Layer Value | View Type |
---|---|
h | Roads only |
m | Standard roadmap (street map) |
p | Terrain |
r | Somehow altered roadmap |
s | Satellite only |
t | Terrain only |
y | Hybrid |
Output:
Conclusion:
I hope you enjoyed learning how to show different Google Map views in the .NET MAUI Maps (SfMaps).
You can refer to our .NET MAUI Maps feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI Maps documentation to understand how to present and manipulate data.
For current customers, you can check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI Maps and other .NET MAUI components.
Please let us know in the comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!