We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use Custom map provider with Xamarin.Android to use google api

Thread ID:

Created:

Updated:

Platform:

Replies:

147095 Sep 1,2019 12:23 PM UTC Sep 9,2019 05:12 AM UTC Xamarin.Android 3
loading
Tags: SfMaps
Rohit
Asked On September 1, 2019 12:23 PM UTC

I am trying to use Sfmaps within Xamarin.Android project and want to use Custom Map providers to refer google api. 
But cannot find any documentation for doing same. (only for Xamarin.Forms is found)

Rachel A [Syncfusion]
Replied On September 3, 2019 03:43 AM UTC

Hi Rohit, 
 
Greetings from Syncfusion. 
 
We can achieve the requirement by overriding the GetUri method in imagery layer as in the code snippet below. 
 
[C#] 
 
public class MainActivity : AppCompatActivity 
    { 
        protected override void OnCreate(Bundle savedInstanceState) 
        { 
            base.OnCreate(savedInstanceState); 
            Xamarin.Essentials.Platform.Init(this, savedInstanceState); 
 
            SfMaps maps = new SfMaps(this); 
            ImagerLayerExt layer = new ImagerLayerExt(); 
            maps.Layers.Add(layer); 
            SetContentView(maps); 
        } 
} 
 
public class ImagerLayerExt:ImageryLayer 
    { 
        protected override string GetUri(int X, int Y, int Scale) 
        { 
            var link = "http://mt1.google.com/vt/lyrs=y&x=" + X.ToString() 
        + "&y=" + Y.ToString() + "&z=" + Scale.ToString(); 
            return link; 
        } 
    } 
 
Output: 
 
 
 
Please let us know if you have any concerns. 
 
Thanks, 
Rachel. 


Rohit
Replied On September 7, 2019 10:36 AM UTC

Thanks  for response. It worked.

Rachel A [Syncfusion]
Replied On September 9, 2019 05:12 AM UTC

Hi Rohit, 
 
We are glad to know that your requirement is satisfied. 
 
Please let us know if you have any other queries. 
 
Thanks, 
Rachel. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon