RedCorners.Forms.GoogleMaps 5.30.5

Enhanced Google Maps for Xamarin Forms (iOS and Android).

Requires NuGet 2.8.3 or higher.

Install-Package RedCorners.Forms.GoogleMaps -Version 5.30.5
dotnet add package RedCorners.Forms.GoogleMaps --version 5.30.5
<PackageReference Include="RedCorners.Forms.GoogleMaps" Version="5.30.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RedCorners.Forms.GoogleMaps --version 5.30.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Enhanced Google Maps for Xamarin Forms. Xamarin.Forms.GoogleMaps fork.

Nuget: https://www.nuget.org/packages/RedCorners.Forms.GoogleMaps
Documentation: http://redcorners.com/googlemaps/

Getting Started

RedCorners.Forms.GoogleMaps provides facilities to render and manage Google Maps based views on your iOS and Android Xamarin.Forms projects. In order to use RedCorners.Forms.GoogleMaps, you need to have the latest versions of the following packages installed:

In case you wish to access the device's location, you must ask for the required permissions prior to enabling My Location on the Google Maps view. Otherwise, the app will throw an exception due to the lack of required location permissions, or will not show My Location. These steps are platform-dependent and described below.

iOS Setup

In your AppDelegate class, or before rendering the map, you have to call the Init method and inject your Google Maps API key:

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
    global::Xamarin.Forms.Forms.Init();
    RedCorners.Forms.GoogleMapsSystem.Init("AIzaSyD8-xxxxxxxxxxxxxxxxxxxxxxxx");
    // ...
    LoadApplication(new App());
    return base.FinishedLaunching(app, options);
}

Based on your use case, you need to configure the info.plist file as follows:

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs access to location to continue.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs access to location to continue.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location to continue.</string>

Android Setup

You have to initialize RedCorners.Forms.GoogleMaps before using it. Typically you can do this in your MainActivity.cs:

protected override void OnCreate(Bundle savedInstanceState)
{
    TabLayoutResource = Resource.Layout.Tabbar;
    ToolbarResource = Resource.Layout.Toolbar;

    base.OnCreate(savedInstanceState);
    Xamarin.Forms.Forms.Init(this, savedInstanceState);
    
    // Initialize RedCorners.Forms.GoogleMaps
    RedCorners.Forms.GoogleMapsSystem.Init(this, savedInstanceState);

    LoadApplication(new App());

    // Optional: Ask for Location Permissions
    if (
        (ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) != Permission.Granted) ||
        (ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessCoarseLocation) != Permission.Granted))
    {
        ActivityCompat.RequestPermissions(this, new [] {
            Manifest.Permission.AccessFineLocation,
            Manifest.Permission.AccessCoarseLocation}, 1);
    };
}

Depending on your use case, you may want to request Fine or Coarse locations. To do this, first add the following lines in your AndroidManifest.xml file:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

You should also add your API key to the manifest:

<meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyD8-xxxxxxxxxxxxxxxxxxxxxxxx" />

In case you get the java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion; error, the following line can help:

<uses-library android:name="org.apache.http.legacy" android:required="false" />

The entire manifest can look like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:versionCode="1" 
    android:versionName="1.0" 
    package="com.redcorners.googlemaps">
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
	<application android:label="RedCorners.Forms.GoogleMaps.Demo.Android">
        <uses-library android:name="org.apache.http.legacy" android:required="false" />
        <meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyD8-xxxxxxxxxxxxxxxxxxxxxxxx" />
    </application>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>

Showing a basic map

The first step is including the RedCorners.Forms.GoogleMaps namespace in your XAML file:

xmlns:map="clr-namespace:RedCorners.Forms.GoogleMaps;assembly=RedCorners.Forms.GoogleMaps"

Afterwards, you can use map:Map or other variants of it such as map:LocationPickerView or map:MapDrawView to show a Google Map:

<map:Map
    MyLocationEnabled="True"
	IsMyLocationButtonVisible="True"
    Latitude="{Binding Latitude, Mode=TwoWay}" 
    Longitude="{Binding Longitude, Mode=TwoWay}">
</map:Map>

Enhanced Google Maps for Xamarin Forms. Xamarin.Forms.GoogleMaps fork.

Nuget: https://www.nuget.org/packages/RedCorners.Forms.GoogleMaps
Documentation: http://redcorners.com/googlemaps/

Getting Started

RedCorners.Forms.GoogleMaps provides facilities to render and manage Google Maps based views on your iOS and Android Xamarin.Forms projects. In order to use RedCorners.Forms.GoogleMaps, you need to have the latest versions of the following packages installed:

In case you wish to access the device's location, you must ask for the required permissions prior to enabling My Location on the Google Maps view. Otherwise, the app will throw an exception due to the lack of required location permissions, or will not show My Location. These steps are platform-dependent and described below.

iOS Setup

In your AppDelegate class, or before rendering the map, you have to call the Init method and inject your Google Maps API key:

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
    global::Xamarin.Forms.Forms.Init();
    RedCorners.Forms.GoogleMapsSystem.Init("AIzaSyD8-xxxxxxxxxxxxxxxxxxxxxxxx");
    // ...
    LoadApplication(new App());
    return base.FinishedLaunching(app, options);
}

Based on your use case, you need to configure the info.plist file as follows:

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs access to location to continue.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs access to location to continue.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location to continue.</string>

Android Setup

You have to initialize RedCorners.Forms.GoogleMaps before using it. Typically you can do this in your MainActivity.cs:

protected override void OnCreate(Bundle savedInstanceState)
{
    TabLayoutResource = Resource.Layout.Tabbar;
    ToolbarResource = Resource.Layout.Toolbar;

    base.OnCreate(savedInstanceState);
    Xamarin.Forms.Forms.Init(this, savedInstanceState);
    
    // Initialize RedCorners.Forms.GoogleMaps
    RedCorners.Forms.GoogleMapsSystem.Init(this, savedInstanceState);

    LoadApplication(new App());

    // Optional: Ask for Location Permissions
    if (
        (ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) != Permission.Granted) ||
        (ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessCoarseLocation) != Permission.Granted))
    {
        ActivityCompat.RequestPermissions(this, new [] {
            Manifest.Permission.AccessFineLocation,
            Manifest.Permission.AccessCoarseLocation}, 1);
    };
}

Depending on your use case, you may want to request Fine or Coarse locations. To do this, first add the following lines in your AndroidManifest.xml file:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

You should also add your API key to the manifest:

<meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyD8-xxxxxxxxxxxxxxxxxxxxxxxx" />

In case you get the java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion; error, the following line can help:

<uses-library android:name="org.apache.http.legacy" android:required="false" />

The entire manifest can look like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:versionCode="1" 
    android:versionName="1.0" 
    package="com.redcorners.googlemaps">
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
	<application android:label="RedCorners.Forms.GoogleMaps.Demo.Android">
        <uses-library android:name="org.apache.http.legacy" android:required="false" />
        <meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyD8-xxxxxxxxxxxxxxxxxxxxxxxx" />
    </application>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>

Showing a basic map

The first step is including the RedCorners.Forms.GoogleMaps namespace in your XAML file:

xmlns:map="clr-namespace:RedCorners.Forms.GoogleMaps;assembly=RedCorners.Forms.GoogleMaps"

Afterwards, you can use map:Map or other variants of it such as map:LocationPickerView or map:MapDrawView to show a Google Map:

<map:Map
    MyLocationEnabled="True"
	IsMyLocationButtonVisible="True"
    Latitude="{Binding Latitude, Mode=TwoWay}" 
    Longitude="{Binding Longitude, Mode=TwoWay}">
</map:Map>

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
5.30.5 45 9/11/2019
5.26.4 61 8/11/2019
5.26.3 53 8/11/2019
5.24.2 63 8/5/2019
5.24.1 58 8/5/2019
5.17.1 60 7/14/2019
5.12.0 66 7/7/2019
4.11.0 63 6/20/2019
4.10.0 61 6/18/2019
4.9.0 64 6/15/2019
4.1.0 85 5/13/2019
4.0.5 82 5/12/2019
4.0.1-alpha 66 5/9/2019