Forum Xamarin.Android

How to load local tiles as overlays in maps application?

PhilipJohnPhilipJohn USMember ✭✭✭

I'm trying to load a large number of tile overlays from a folder in Assets in my Android project. I can get tiles to load from a remote url, but not from a local folder. Any ideas what I'm doing wrong here?

In my Activity

 public void OnMapReady(GoogleMap map)
            map.MapType = GoogleMap.MapTypeNormal;
            var options = new TileOverlayOptions();
            options.InvokeTileProvider(new LocalTileProvider());

and the UrlTileProvider

public class LocalTileProvider : UrlTileProvider
        public LocalTileProvider() : base(256, 256)

        public override URL GetTileUrl(int x, int y, int z)
            string s = "file:///android_asset/tiles/" + z.ToString() + "/" + y.ToString() + "/" + x.ToString() + ".jpg";
            //string s = "" + z + "/" + x + "/" + y + ".png"; // <= this works

            return new URL(s);

Best Answer


  • PhilipJohnPhilipJohn USMember ✭✭✭

    @LandLu Many thanks. I was stuck on this for hours. Works fine now.

  • tnxtnx USMember

    @PhilipJohn Would you mind to share your solution code with multiple tile images?


  • PhilipJohnPhilipJohn USMember ✭✭✭

    @tnx I'm really sorry, but I no longer have access to that code.

Sign In or Register to comment.