ThinkGeo.com    |     Documentation    |     Premium Support

How to draw image tile using XYZ and CurrentExtent as reference to a mapview?

any sample code on how to draw image tile using XYZ and CurrentExtent as reference to a mapview?
I think XYZ server and also raster tile mbtiles as a background layer would be a big plus for ThinkGeo.

what do you think?

TileMatrix.GetIntersectingCells() gives you the coordinates.

But it would be easier to derive a class from XyzTileLayer and implement GetImageUriCore().

any documention available for xyztilelayer?

Hi gisnoob,

As of right now, we don’t have documents for xyztilelayer. Clemens_Ladisch is right, you could derive a class from XyzTileLayer, and implement GetImageUriCore(). In this method, you could use parameters zoomLevel, x, y and resolutionFactor to calculate and generate the correct url.

Here’s some sample code:

    protected override Uri GetImageUriCore(int zoomLevel, long x, long y, float resolutionFactor)
    {
        List<Uri> urlTemplates = customServerUris.Count > 0 ? new List<Uri>(customServerUris) : new List<Uri>(DefaultUris);

        int selectIndex = (int)Math.Abs(((y << zoomLevel) + x) % urlTemplates.Count);

        string url = string.Format(CultureInfo.InvariantCulture, urlTemplates[selectIndex].OriginalString, zoomLevel, x, y);

        return new Uri(url);
    }

Thanks,
Leo