<?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>icons on google map Archives - Nerd Corner</title>
	<atom:link href="https://nerd-corner.com/tag/icons-on-google-map/feed/" rel="self" type="application/rss+xml" />
	<link>https://nerd-corner.com/tag/icons-on-google-map/</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>icons on google map Archives - Nerd Corner</title>
	<link>https://nerd-corner.com/tag/icons-on-google-map/</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=1756338578" 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=1756338578" 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=1756338578" 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>
	</channel>
</rss>
