RedCorners.Forms.GoogleMaps
8.59.36-alpha
See the version list below for details.
Requires NuGet 2.8.3 or higher.
dotnet add package RedCorners.Forms.GoogleMaps --version 8.59.36-alpha
NuGet\Install-Package RedCorners.Forms.GoogleMaps -Version 8.59.36-alpha
<PackageReference Include="RedCorners.Forms.GoogleMaps" Version="8.59.36-alpha" />
paket add RedCorners.Forms.GoogleMaps --version 8.59.36-alpha
#r "nuget: RedCorners.Forms.GoogleMaps, 8.59.36-alpha"
// Install RedCorners.Forms.GoogleMaps as a Cake Addin #addin nuget:?package=RedCorners.Forms.GoogleMaps&version=8.59.36-alpha&prerelease // Install RedCorners.Forms.GoogleMaps as a Cake Tool #tool nuget:?package=RedCorners.Forms.GoogleMaps&version=8.59.36-alpha&prerelease
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>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. monoandroid10 is compatible. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. xamarinios10 is compatible. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
All Frameworks
- Neat.Map.Models (>= 1.0.1)
- RedCorners (>= 8.0.0)
- RedCorners.Forms (>= 8.59.0)
- Xamarin.Forms (>= 5.0.0.1874)
-
MonoAndroid 1.0
- Xamarin.GooglePlayServices.Maps (>= 117.0.0)
-
Xamarin.iOS 1.0
- Xamarin.Build.Download (>= 0.10.0)
- Xamarin.Google.iOS.Maps (>= 3.9.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
90.0.0 | 418 | 7/14/2024 |
8.59.40 | 1,802 | 7/21/2021 |
8.59.39 | 1,438 | 2/10/2021 |
8.59.38 | 931 | 1/23/2021 |
8.59.37 | 881 | 1/23/2021 |
8.59.36-alpha | 777 | 1/9/2021 |
8.50.37 | 933 | 12/14/2020 |
8.50.36 | 888 | 12/9/2020 |
8.50.35 | 895 | 12/9/2020 |
8.50.34 | 870 | 11/28/2020 |
8.50.33 | 879 | 11/28/2020 |
8.50.32 | 1,015 | 10/26/2020 |
8.50.30 | 997 | 10/25/2020 |
8.50.29 | 1,004 | 10/25/2020 |
8.50.28 | 977 | 10/25/2020 |
8.50.27 | 889 | 10/25/2020 |
8.50.26 | 893 | 10/25/2020 |
8.50.25 | 936 | 10/25/2020 |
8.50.24 | 963 | 10/25/2020 |
8.50.23 | 1,044 | 10/24/2020 |
8.46.22 | 974 | 8/30/2020 |
8.46.21 | 1,086 | 7/23/2020 |
8.46.20 | 993 | 3/17/2020 |
6.41.19 | 1,212 | 1/12/2020 |
6.41.18 | 999 | 1/12/2020 |
6.41.17 | 1,074 | 1/11/2020 |
6.41.16 | 978 | 12/30/2019 |
6.41.15 | 946 | 12/30/2019 |
6.41.14 | 1,018 | 12/30/2019 |
6.41.13 | 980 | 12/18/2019 |
6.41.12 | 994 | 12/18/2019 |
5.39.11 | 957 | 12/2/2019 |
5.36.10 | 985 | 11/27/2019 |
5.36.9 | 1,030 | 11/24/2019 |
5.33.7 | 979 | 11/15/2019 |
5.33.6 | 1,003 | 11/1/2019 |
5.30.5 | 1,052 | 9/11/2019 |
5.26.4 | 1,071 | 8/11/2019 |
5.26.3 | 1,037 | 8/11/2019 |
5.24.2 | 1,008 | 8/5/2019 |
5.24.1 | 1,017 | 8/5/2019 |
5.17.1 | 1,041 | 7/14/2019 |
5.12.0 | 1,041 | 7/7/2019 |
4.11.0 | 1,040 | 6/20/2019 |
4.10.0 | 1,021 | 6/18/2019 |
4.9.0 | 1,050 | 6/15/2019 |
4.1.0 | 1,088 | 5/13/2019 |
4.0.5 | 1,032 | 5/12/2019 |
4.0.1-alpha | 866 | 5/9/2019 |