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. Image for the cookie policy date

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

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)

3 Replies

RA Rachel A Syncfusion Team 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. 



RO Rohit September 7, 2019 10:36 AM UTC

Thanks  for response. It worked.


RA Rachel A Syncfusion Team 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. 


Loader.
Live Chat Icon For mobile
Up arrow icon