This project is read-only.

Custom tile source

Dec 9, 2010 at 10:05 PM

We are planning to develop a tile source. I assume we have to, at least, implement Uri GetTile(int tileLevel, int tilePositionX, int tilePositionY). My question is how to calculate the bounding box of the tile with these three parameters in geographic or logical units.

 

Thanks.

Dec 10, 2010 at 1:06 AM

if you look in the older sl3 version there is a tile source which has a bit of code to convert to a Bounding Box, this was for a WMS tile source, but the WMS tiles are generally a different projection so that tiles actually warp/stretch at different zoom levels

Dec 17, 2010 at 3:03 PM

Thanks. I could find that source and used it a guide. Now we can display our tile source on top of the BaseLayer by adding it to the BaseLayer's Overlays.

Now I have another problem. We would like to add our source to the Layers collection. The following code in TileSource.cs requires a tile source be both ILayer and ITileSource. Is this intentional?


                if (_MapInstance.Layers != null && _MapInstance.Layers.Count > 0)
                {
                    foreach (ILayer me in _MapInstance.Layers)
                    {
                        if (me is ITileSource)
                        {
                            //Add additional images sources if available
                            Uri uri = (me as ITileSource).GetTile(tileLevel, tilePositionX, tilePositionY);
                            if (uri != null) tileSources.Add(uri);
                        }
                    }
                }
I think it must be something like
                if (_MapInstance.Layers != null && _MapInstance.Layers.Count > 0)
                {
                    foreach (ILayer me in _MapInstance.Layers)
                    {
                        if (me is TileLayer)
                        {
                            //Add additional images sources if available
                            Uri uri = (me as TileLayer).Source.GetTile(tileLevel, tilePositionX, tilePositionY);
                            if (uri != null) tileSources.Add(uri);
                        }
                    }
                }

Has anyone tired to add a tile source or tile layer to Layers collection?