Skip to main content

Open the Map App

Get started​

To access the map functionality, the following platform-specific setup is required.

Android​

Android uses the geo: URI scheme to launch the maps application on the device. This may prompt the user to select from an existing app that supports this URI scheme. Google Maps supports this scheme.

In the Platforms/Android/AndroidManifest.xml file, add the following queries/intent nodes to the manifest node:

<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="geo"/>
</intent>
</queries>

Using the map​

The map functionality works by calling the Device.Map.TryOpenAsync() method, and passing either an instance of the Location or Placemark type. The following example opens the installed map app at a specific GPS location:

public async Task NavigateToBuilding25()
{
var location = new Location(47.645160, -122.1306032);
var options = new MapLaunchOptions { Name = "Microsoft Building 25" };

bool opened = await Device.Map.TryOpenAsync(location, options);
}
info

The Location, Placemark and MapLaunchOptions types are in the Wisej.Hybrid namespace.

When you use a Placemark to open the map, more information is required. The information helps the map app search for the place you're looking for. The following information is required:

  • CountryName
  • AdminArea
  • Thoroughfare
  • Locality
public async Task NavigateToBuilding()
{
var placemark = new Placemark
{
CountryName = "United States",
AdminArea = "WA",
Thoroughfare = "Microsoft Building 25",
Locality = "Redmond"
};
var options = new MapLaunchOptions { Name = "Microsoft Building 25" };

bool opened = await Device.Map.TryOpenAsync(placemark, options);
}

API reference​

Device API. See Platform Capabilities before relying on native behavior.