Articles in this section
Category / Section

How to Use Google Maps API to Show Google Maps in the .NET MAUI Maps (SfMaps)

4 mins read

In the Syncfusion .NET MAUI Maps control, you can use Google Maps API by following this demonstration.

Step 1:
Initialize the SfMaps control and initiate the MapTileLayer.

XAML:

<map:SfMaps VerticalOptions="Center"
           HorizontalOptions="Center">
   <map:SfMaps.Layer>
       <map:MapTileLayer x:Name="layer">
           <map:MapTileLayer.MarkerTemplate>
               <DataTemplate>
                   <StackLayout HorizontalOptions="Start"
                                VerticalOptions="Center">
                       <Image Source="pin.png"
                              HeightRequest="20"
                              WidthRequest="20" />
                   </StackLayout>
               </DataTemplate>
           </map:MapTileLayer.MarkerTemplate>
           <map:MapTileLayer.Markers>
               <map:MapMarkerCollection>
                   <map:MapMarker Latitude="37.785834"
                                  Longitude="-122.406417" />
                   <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>

Step 2:
Set the URL template to the MapTileLayer using the URLTemplate property.

C#:

public MainPage()
{
   InitializeComponent();
   this.layer.UrlTemplate = "https://mt0.google.com/vt/lyrs=y&x={x}&amp;y={y}&amp;z={z}";
}

Output:

GoogleMaps.png

View the sample on GitHub.

Conclusion:
I hope you enjoyed learning how to use Google Maps API to show Google Maps in the .NET MAUI Maps (SfMaps).

Refer to our .NET MAUI Maps feature tour page to learn about its other groundbreaking feature representations. You can explore our .NET MAUI Maps documentation to understand how to present and manipulate data.

For current customers, 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 following comments section if you have any queries or require clarifications. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please  to leave a comment
Access denied
Access denied