amay077 / Xamarin.Forms.GoogleMaps

Map library for Xamarin.Forms using Google maps API
https://www.nuget.org/packages/Xamarin.Forms.GoogleMaps/
MIT License
546 stars 346 forks source link

TileLayer.FromTileUri doesn't work #697

Open jannikscho opened 4 years ago

jannikscho commented 4 years ago

VERSIONS

PLATFORMS

ACTUAL BEHAVIOR

TileLayer.FromTileUri doesn't show any Layer.

// this works as expected and show layers
var tile = TileLayer.FromAsyncImage(
            (int x, int y, int zoom) =>
            {
                    var bbox = GetBoundingBox(x, y, zoom); // Calculates the Boundings
                    var uri = GetTileLayerUri(layer, bbox); // Creates the TileLayerUri
                    var image = new System.Net.WebClient().DownloadData(uri);
                    return Task.FromResult(image);
            });

/* this works, too
var tile = TileLayer.FromSyncImage(
            (int x, int y, int zoom) =>
            {
                var bbox = GetBoundingBox(x, y, zoom);
                var uri = GetTileLayerUri(layer, bbox);
                return new System.Net.WebClient().DownloadData(uri);
            });
*/

// this doesn't show any layer
var tile = TileLayer.FromTileUri(
            (int x, int y, int zoom) =>
            {
                var bbox = GetBoundingBox(x, y, zoom); // Calculates the Boundings
                var uri = GetTileLayerUri(layer, bbox); // Creates the TileLayerUri
                return uri;
            });

//tile.ZIndex = -1;
tile.Tag = layer;
TileLayers.Add(tile);

The generated Uris look like this: http://geodienste.bfn.de/ogc/wms/schutzgebiet?service=WMS&version=1.1.0&request=GetMap&typename=bfn_sch_wfs_schutzgebiet:Naturschutzgebiete&layers=Naturschutzgebiete&styles=&bbox=792499.109462544,6653078.94363616,802283.049085539,6662862.88325916&width=256&height=256&srs=EPSG:3857&format=image/png&transparent=true

When you open the Url, you will see the layer. When using FromSyncImage or FromAsyncImage the layers will be shown as expected. But when i use FromTileUri, no layers will be visible.