<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>custom Google Maps marker Archives - Nerd Corner</title>
	<atom:link href="https://nerd-corner.com/tag/custom-google-maps-marker/feed/" rel="self" type="application/rss+xml" />
	<link>https://nerd-corner.com/tag/custom-google-maps-marker/</link>
	<description>Craft your dreams!</description>
	<lastBuildDate>Mon, 24 Oct 2022 14:45:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>

<image>
	<url>https://nerd-corner.com/wp-content/uploads/2019/10/cropped-LogoNerdCorner-2-32x32.png</url>
	<title>custom Google Maps marker Archives - Nerd Corner</title>
	<link>https://nerd-corner.com/tag/custom-google-maps-marker/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to add custom icon pins to Google Maps Xamarin App</title>
		<link>https://nerd-corner.com/how-to-add-custom-icon-pins-to-google-maps-xamarin-app/</link>
					<comments>https://nerd-corner.com/how-to-add-custom-icon-pins-to-google-maps-xamarin-app/#comments</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Mon, 13 Apr 2020 11:51:24 +0000</pubDate>
				<category><![CDATA[App development]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[App with Google Maps]]></category>
		<category><![CDATA[custom Google Maps marker]]></category>
		<category><![CDATA[custom Google Maps pin]]></category>
		<category><![CDATA[icons on google map]]></category>
		<category><![CDATA[Xamarin]]></category>
		<category><![CDATA[Xamarin Forms]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/?p=508</guid>

					<description><![CDATA[<p>We explained in the last post how to integrate Google Maps in a Xamarin Forms application. In this post we make a further step an &#8230; </p>
<p>The post <a href="https://nerd-corner.com/how-to-add-custom-icon-pins-to-google-maps-xamarin-app/">How to add custom icon pins to Google Maps Xamarin App</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We explained in the <a href="https://nerd-corner.com/how-to-integrate-google-maps-in-an-app-with-xamarin/">last post</a> how to integrate Google Maps in a Xamarin Forms application. In this post we make a further step an show you how to change the standard Google Maps marker pin to custom icon pins in Google Maps.</p>
<h2>List of components</h2>
<ul>
<li>Visual Studio (free)</li>
</ul>
<h2>Setting a pin on the Google Map an choose a starting point</h2>
<p>Let&#8217;s start to put a few markers on the map. The code is pretty simple. In the &#8220;MainPage.xaml.cs&#8221; include the following using directive:</p>
<pre>using Xamarin.Forms.GoogleMaps;</pre>
<p>Then create a pin with position and label:</p>
<pre><code>Pin one = new Pin ()
{
    Label = "Pin ONE",
    Position = new position (48.1390196, 11.5744422)
};
MyMap.Pins.Add (one);</code></pre>
<p>&#8220;MyMap&#8221; is the name we have set in the &#8220;MainPage.xaml&#8221;.</p>
<p>The following code can be used to ensure that the map always opens at a specific starting point:</p>
<pre><code>MyMap.MoveToRegion (MapSpan.FromCenterAndRadius (new Position (48.1390196, 11.5744422), Distance.FromKilometers (10)));</code></pre>
<p>And this is how the app looks now:</p>
<p><img fetchpriority="high" decoding="async" class="aligncenter wp-image-495 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_standard_pins.jpg" alt="Screenshot Google Maps in App" width="310" height="620" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_standard_pins.jpg 1080w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_standard_pins-150x300.jpg 150w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_standard_pins-512x1024.jpg 512w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_standard_pins-768x1536.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_standard_pins-1024x2048.jpg 1024w" sizes="(max-width: 310px) 100vw, 310px" /></p>
<h2>Add new icons</h2>
<p><span style="font-size: 1.125rem;">I downloaded two alternative icons i</span>n order to replace the red Google standard pins. I have the &#8220;castle.png&#8221; and &#8220;beer.png&#8221; icon from the website <a href="http://icons8.com">icons8.com</a>.</p>
<p>For iOS, we simply drag the two icons to the &#8220;Resources&#8221; folder in the iOS project. It should look like this:</p>
<p><img decoding="async" class="aligncenter wp-image-510 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_iOS.jpg" alt="Add pictures to Xamarin Forms iOS project NErd Corner" width="1599" height="847" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_iOS.jpg 1600w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_iOS-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_iOS-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_iOS-768x407.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_iOS-1536x814.jpg 1536w" sizes="(max-width: 1599px) 100vw, 1599px" /></p>
<p>For Android we drag the icons to the &#8220;drawable&#8221; folder under &#8220;Resources&#8221; in the Android project. For me it is unfortunately always the case that the &#8220;drawable&#8221; folder has to be created manually. Although, it is displayed normally in the Visual Studio folder structure, it actually doesn&#8217;t really exist if you search the folder on your computer. So create a new folder, where the really &#8220;drawable&#8221; folder should be and name it &#8220;drawable&#8221;. Restart Visual Studio and then add the two icons. It looks like this:</p>
<p><img decoding="async" class="aligncenter wp-image-511 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_Android.jpg" alt="Visual Studio Xamarin how to integrate icons in the drawable folder Nerd Corner" width="1599" height="848" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_Android.jpg 1600w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_Android-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_Android-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_Android-768x408.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_Android-1536x815.jpg 1536w" sizes="(max-width: 1599px) 100vw, 1599px" /></p>
<h2>Extra step for Android users: Create a Bitmap class</h2>
<p>iOS has a clear advantage here. You don&#8217;t have to do anything for Apple phones. iOS automatically renders the icons from the &#8220;Resources&#8221; folder. For Android, however, you have one extra step, but you are almost there.</p>
<p>Create a class in the ANDROID project, name it &#8220;BitmapConfig.cs&#8221; and copy the following code:</p>
<pre><code>
using DemoGoogleMapApp.Droid;
using Xamarin.Forms.GoogleMaps;
using Xamarin.Forms.GoogleMaps.Android.Factories;
using AndroidBitmapDescriptor = Android.Gms.Maps.Model.BitmapDescriptor;
using AndroidBitmapDescriptorFactory = Android.Gms.Maps.Model.BitmapDescriptorFactory;

public sealed class BitmapConfig : IBitmapDescriptorFactory
{
    public AndroidBitmapDescriptor ToNative(BitmapDescriptor descriptor)
    {
        int iconId = 0;
        switch (descriptor.Id)
        {
            case "castle":
                iconId = Resource.Drawable.castle;
                break;
            case "beer":
                iconId = Resource.Drawable.beer;
                break;
        }
        return AndroidBitmapDescriptorFactory.FromResource(iconId);
    }
}
</code></pre>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-513 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_BitmapConfig.jpg" alt="Visual Studio Xamarin Bitmap Config for custom icon google maps pin Nerd Corner" width="1599" height="847" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_BitmapConfig.jpg 1600w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_BitmapConfig-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_BitmapConfig-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_BitmapConfig-768x407.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_BitmapConfig-1536x814.jpg 1536w" sizes="auto, (max-width: 1599px) 100vw, 1599px" /><br />
You can create an extra case for each icon. We can then assign a case name to each pin on the map.</p>
<p>In the &#8220;MainActivity.cs&#8221; the Google Maps initialization also has to be changed a little bit. Add the following using directive and the new initialization code.</p>
<p>Using directive:</p>
<pre>using Xamarin.Forms.GoogleMaps.Android</pre>
<p>Initialization code:</p>
<pre><code>
var platformConfig = new PlatformConfig
{
    BitmapDescriptorFactory = new BitmapConfig()
};
Xamarin.FormsGoogleMaps.Init(this, savedInstanceState, platformConfig);
</code></pre>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-514 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot-Bitmap-Config-in-Main-Activity.jpg" alt="Bitmap Config for custom google pins in main activation function android Nerd Corner" width="1599" height="848" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot-Bitmap-Config-in-Main-Activity.jpg 1600w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot-Bitmap-Config-in-Main-Activity-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot-Bitmap-Config-in-Main-Activity-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot-Bitmap-Config-in-Main-Activity-768x408.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot-Bitmap-Config-in-Main-Activity-1536x815.jpg 1536w" sizes="auto, (max-width: 1599px) 100vw, 1599px" /></p>
<p>I got the idea for the &#8220;BitmapConfig.cs&#8221; from this <a href="https://medium.com/@dev.aritradas/using-custom-markers-and-latitude-longitude-bounds-in-google-maps-on-xamarin-forms-690babde96ff">post</a>.</p>
<h2>Last step: Add the custom icon pins in Google Maps app</h2>
<p>From now on you can easily set the icon image for each pin on the Google Map:</p>
<pre><code>
Pin one = new Pin()
{
    Label="Pin ONE",
    Position= new Position(48.1390196, 11.5744422),
    Icon= BitmapDescriptorFactory.FromBundle("beer"),
    Type = PinType.Place
};
</code></pre>
<p>Each icon can be used as a Google Maps Pin with the following assignment:</p>
<pre>Icon = BitmapDescriptorFactory.FromBundle ("NameOfTheCase")</pre>
<h2>Screenshots of the custom icon pins in Google Maps app</h2>
<p><img loading="lazy" decoding="async" class="alignleft wp-image-520 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_two_end.jpg" alt="Screenshot Xamarin Forms App with custom Google Maps Pin marker image Nerd Corner" width="200" height="400" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_two_end.jpg 1080w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_two_end-150x300.jpg 150w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_two_end-512x1024.jpg 512w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_two_end-768x1536.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_two_end-1024x2048.jpg 1024w" sizes="auto, (max-width: 200px) 100vw, 200px" /> <img loading="lazy" decoding="async" class="alignleft wp-image-519 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_one_end.jpg" alt="Screenshot Xamarin Forms App with custom Google Maps Pin marker image Nerd Corner" width="200" height="400" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_one_end.jpg 1080w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_one_end-150x300.jpg 150w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_one_end-512x1024.jpg 512w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_one_end-768x1536.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_one_end-1024x2048.jpg 1024w" sizes="auto, (max-width: 200px) 100vw, 200px" /> <img loading="lazy" decoding="async" class="alignleft wp-image-518 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pins.jpg" alt="Screenshot Xamarin Forms App with custom Google Maps Pin marker image Nerd Corner" width="200" height="400" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pins.jpg 1080w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pins-150x300.jpg 150w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pins-512x1024.jpg 512w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pins-768x1536.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pins-1024x2048.jpg 1024w" sizes="auto, (max-width: 200px) 100vw, 200px" /> <img loading="lazy" decoding="async" class="wp-image-517 zoooom alignleft" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pin_with_label.jpg" alt="Screenshot Xamarin Forms App with custom Google Maps Pin marker image Nerd Corner" width="200" height="400" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pin_with_label.jpg 1080w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pin_with_label-150x300.jpg 150w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pin_with_label-512x1024.jpg 512w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pin_with_label-768x1536.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pin_with_label-1024x2048.jpg 1024w" sizes="auto, (max-width: 200px) 100vw, 200px" /></p>
<h2>Download files</h2>
<ul>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/530/?tmstv=1755869185" rel="nofollow" id="download-link-530" data-redirect="false" >
	Source Code Xamarin Forms Google Maps App with custom icon</a>
</li>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/533/?tmstv=1755869185" rel="nofollow" id="download-link-533" data-redirect="false" >
	Icons</a>
</li>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/536/?tmstv=1755869185" rel="nofollow" id="download-link-536" data-redirect="false" >
	BitmapConfig.cs AndroidManifest.xml MainActivity.cs</a>
</li>
</ul>
<p>Please don&#8217;t forget to insert your Google Maps API Key in the source code.</p>
<p>&nbsp;</p>
<p>The post <a href="https://nerd-corner.com/how-to-add-custom-icon-pins-to-google-maps-xamarin-app/">How to add custom icon pins to Google Maps Xamarin App</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/how-to-add-custom-icon-pins-to-google-maps-xamarin-app/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>How to integrate Google Maps in an App with Xamarin</title>
		<link>https://nerd-corner.com/how-to-integrate-google-maps-in-an-app-with-xamarin/</link>
					<comments>https://nerd-corner.com/how-to-integrate-google-maps-in-an-app-with-xamarin/#comments</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Mon, 13 Apr 2020 10:53:42 +0000</pubDate>
				<category><![CDATA[App development]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[App with Google Maps]]></category>
		<category><![CDATA[custom Google Maps marker]]></category>
		<category><![CDATA[custom Google Maps pin]]></category>
		<category><![CDATA[Xamarin]]></category>
		<category><![CDATA[Xamarin Forms]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/?p=491</guid>

					<description><![CDATA[<p>This post explains how to integrate Google Maps in an app. The app is a Xamarin Forms application. Xamarin is a cross platform for Android &#8230; </p>
<p>The post <a href="https://nerd-corner.com/how-to-integrate-google-maps-in-an-app-with-xamarin/">How to integrate Google Maps in an App with Xamarin</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This post explains how to integrate Google Maps in an app. The app is a Xamarin Forms application. Xamarin is a cross platform for Android and iOS. The programming language is C#. In addition to this post, <a href="https://nerd-corner.com/how-to-add-custom-icon-pins-to-google-maps-xamarin-app/">there will be a post</a>, which describes how to replace the standard Google Map pin with a custom icon.</p>
<h2>List of components</h2>
<ul>
<li>Visual Studio (free)</li>
</ul>
<h2>Downloading the NuGet Package</h2>
<p>Open Visual Studio and choose Mobile App (Xamarin.Forms). In order to use Google Maps, we have to integrate the corresponding NuGet package. Instead of the official version &#8220;Xamarin.Forms.Maps&#8221; by Microsoft, we use &#8220;Xamarin.Forms.GoogleMaps&#8221; by amay077. Please remember to install the NuGet package for each project. The &#8220;Xamarin.Forms.GoogleMaps&#8221; NuGet package by amay077 contains all functions of the official package and some additional ones. Among other things, you can easily replace the markers on the map with your own pictures.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-504 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_NuGet_Paket.jpg" alt="Xamarin Visual Studio Google Maps NuGet Package Nerd Corner" width="1599" height="847" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_NuGet_Paket.jpg 1600w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_NuGet_Paket-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_NuGet_Paket-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_NuGet_Paket-768x407.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_NuGet_Paket-1536x814.jpg 1536w" sizes="auto, (max-width: 1599px) 100vw, 1599px" /></p>
<p>All possible functions of the &#8220;Xamarin.Forms.GoogleMaps&#8221; NuGet package by amay077, to integrate Google Maps in an app, are described on GitHub: <a href="https://github.com/amay077/Xamarin.Forms.GoogleMaps">https://github.com/amay077/Xamarin.Forms.GoogleMaps</a></p>
<h2>XAML code for the Google Map integration</h2>
<p>Since the NuGet package is already installed, Google Maps can now be added to the XAML page. Open &#8220;MainPage.xaml&#8221; and add:</p>
<pre>xmlns: gmaps = "clr-namespace: Xamarin.Forms.GoogleMaps; assembly = Xamarin.Forms.GoogleMaps"</pre>
<p>Then we need the following XAML code to display the map:</p>
<pre><code>
    &lt;Grid&gt;
        &lt;gmaps:Map x:Name="MyMap" MapType="Street" HasZoomEnabled="True" MyLocationEnabled="True" &gt;
            &lt;gmaps:Map.ItemTemplate&gt;
                &lt;DataTemplate&gt;
                    &lt;gmaps:Pin Icon="{Binding PinIcon}" Position="{Binding Position}"
                              Label="{Binding PinLabel}" /&gt;
                &lt;/DataTemplate&gt;
            &lt;/gmaps:Map.ItemTemplate&gt;
        &lt;/gmaps:Map&gt;
    &lt;/Grid&gt;
</code></pre>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-505 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainPage.jpg" alt="Visual Studio Xamarin Forms Google Maps integration Nerd Corner" width="1599" height="847" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainPage.jpg 1600w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainPage-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainPage-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainPage-768x407.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainPage-1536x814.jpg 1536w" sizes="auto, (max-width: 1599px) 100vw, 1599px" /></p>
<h2>Get the Google API Key to integrate Google Maps in an app</h2>
<p>Although we have the XAML code to integrate Google Maps in an app, an API key is required. Otherwise we won&#8217;t see anything. Obtaining the API key from Google is easy and quick.<br />
Simply request the API key here: <a href="https://developers.google.com/maps/documentation/embed/get-api-key">https://developers.google.com/maps/documentation/embed/get-api-key </a></p>
<p><span style="font-size: 1.125rem;">Please note that the keys for iOS and Android are different.</span></p>
<h2>Initialize Google Maps for Android</h2>
<p>These are the final steps to display Google Maps in Android. Open the &#8220;MainActivity.cs&#8221; and add the following line in the &#8220;OnCreate ()&#8221; function:</p>
<pre>Xamarin.FormsGoogleMaps.Init (this, savedInstanceState);</pre>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-506 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainActivity.jpg" alt="Visual Studio Xamarin Integrate Google Maps Line for main activity Nerd Corner" width="1599" height="847" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainActivity.jpg 1600w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainActivity-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainActivity-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainActivity-768x407.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainActivity-1536x814.jpg 1536w" sizes="auto, (max-width: 1599px) 100vw, 1599px" /></p>
<p>Next, go to <span style="font-size: 1.125rem;">&#8220;Properties&#8221; and </span><span style="font-size: 1.125rem;">select &#8220;AndroidManifest.xml&#8221;. We have to insert here the Google API key and grant the rights for GPS.</span></p>
<p>The is the place where you have to put the line with the meta-data for the Google Maps API Key:</p>
<pre>&lt;application android: label "Name of your app"&gt;Add here the meta-data&lt;/application&gt;</pre>
<p>This is the line with the meta-data for the Google Maps API Key:</p>
<pre>&lt;meta-data android: name = "com.google.android.maps.v2.API_KEY" android: value = "AddYourAndroidAPIKeyHere" /&gt;</pre>
<p>Then the rights for the GPS have to be granted:</p>
<pre>&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
&lt;uses-feature android:name="android.hardware.location.gps" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /&gt;
&lt;uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
&lt;uses-permission android:name="android.permission.INTERNET" /&gt;</pre>
<p>Afterwards the <span style="font-size: 1.125rem;">&#8220;AndroidManifest.xml&#8221; looks like the screenshot here:</span></p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-493 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_AndroidManifest.jpg" alt="Screenshot AndroidManifest for Google Maps API Key" width="1599" height="847" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_AndroidManifest.jpg 1600w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_AndroidManifest-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_AndroidManifest-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_AndroidManifest-768x407.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_AndroidManifest-1536x814.jpg 1536w" sizes="auto, (max-width: 1599px) 100vw, 1599px" /></p>
<h2>Initialize Google Maps for iOS</h2>
<p>The initialization is easier for iOS. You just have to open the &#8220;AppDelegate.cs&#8221; and add the following line:</p>
<pre>Xamarin.FormsGoogleMaps.Init ("AddYouriOSAPIKeyHere");</pre>
<h2>Start the app</h2>
<p>The app is now ready to go. Press compile in Visual Studio, then it looks like this:<br />
<img loading="lazy" decoding="async" class="zoooom aligncenter wp-image-496" data-zoom-image="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_standard.jpg" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_standard-512x1024.jpg" alt="Screenshot Google Maps in App Nerd Corner" width="310" height="620" /><br />
It is normal that the app chooses Rome as starting point. The next post shows how you can implement the starting point of the Google Maps app.</p>
<p>Sometimes it happens that the app does not automatically ask for the required rights and therefore it closes immediately after launching. This can be avoided by simply allowing GPS access in the settings or implementing a command to ask for the required rights.</p>
<h2>Download files</h2>
<ul>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/549/?tmstv=1755869185" rel="nofollow" id="download-link-549" data-redirect="false" >
	Source Code Demo Google Maps App</a>
</li>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/542/?tmstv=1755869185" rel="nofollow" id="download-link-542" data-redirect="false" >
	ActivityMain.cs AndroidManifest.xml MainPage.xaml MainPage.xaml.cs</a>
</li>
</ul>
<p>Please don&#8217;t forget to insert your Google Maps API Key in the source code.</p>
<p>The post <a href="https://nerd-corner.com/how-to-integrate-google-maps-in-an-app-with-xamarin/">How to integrate Google Maps in an App with Xamarin</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/how-to-integrate-google-maps-in-an-app-with-xamarin/feed/</wfw:commentRss>
			<slash:comments>10</slash:comments>
		
		
			</item>
	</channel>
</rss>
