Skip to content

SyncfusionExamples/Integrate-Google-Maps-API-in-.NET-MAUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Integrating Google Maps into .NET MAUI Across All Platforms

TL;DR

  • Native .NET MAUI Map control supports Google Maps only on Android.
  • Apple Maps is used on iOS/macOS, Bing Maps on Windows.
  • This sample uses Google Maps Tile API with Syncfusion SfMaps to render Google Maps tiles across all platforms.

Features

  • Cross-platform Google Maps rendering using tile layers
  • Session token caching for optimized API usage
  • Custom zoom, pan, and center configuration
  • Marker and tooltip support
  • Optional integration with OpenAI for smart location search

Requirements

  • Syncfusion .NET MAUI Maps
  • Google Maps Tile API Key
  • Billing enabled in Google Cloud Console

Setup Instructions

Step 1: Enable Google Maps Tile API

  1. Create a project in Google Cloud Console
  2. Enable billing and Map Tiles API
  3. Generate an API key

Step 2: Create a Session Token

API endpoint:

https://tile.googleapis.com/v1/createSession?key=YOUR_API_KEY

Step 3: Cache Session Token

Use Preferences.Set and Preferences.Get to store and reuse session tokens until expiry.

Step 4: Configure SfMaps

Example XAML:

<maps:SfMaps x:Name="maps">
  <maps:SfMaps.Layer>
    <maps:MapTileLayer x:Name="layer" CanCacheTiles="True">
      <maps:MapTileLayer.Center>
        <maps:MapLatLng Latitude="37.0902" Longitude="-95.7129" />
      </maps:MapTileLayer.Center>
      <maps:MapTileLayer.ZoomPanBehavior>
        <maps:MapZoomPanBehavior ZoomLevel="4" MinZoomLevel="4" MaxZoomLevel="18" EnableDoubleTapZooming="True" />
      </maps:MapTileLayer.ZoomPanBehavior>
    </maps:MapTileLayer>
  </maps:SfMaps.Layer>
</maps:SfMaps>

Set UrlTemplate dynamically:

https://tile.googleapis.com/v1/2dtiles/{z}/{x}/{y}?session=SESSION_TOKEN&key=API_KEY

Optional: AI-Powered Location Search

Refer to Syncfusion blog on Smart Location Search in MAUI Maps. https://www.syncfusion.com/blogs/post/smart-location-search-in-maui-maps

About

This repository contains Integrating Google Maps into .NET MAUI Across All Platforms

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages