Open the Map App

Get started

To access the browser 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.TryOpen() 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 void NavigateToBuilding25()
{
    var location = new Location(47.645160, -122.1306032);
    var options = new MapLaunchOptions { Name = "Microsoft Building 25" };

    bool opened = Device.Map.TryOpen(location, options);
}

The Location and Placemark types are in the Wisej.Hybrid.Shared.Geolocation 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 void 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 = Device.Map.TryOpen(placemark, options);
}

Last updated