This is a migrated thread and some comments may be shown as answers.

MiniMap with custom provider

2 Answers 184 Views
Map
This is a migrated thread and some comments may be shown as answers.
Wang
Top achievements
Rank 1
Wang asked on 19 May 2016, 09:05 AM

Hello,

I want to use custom provider in my project,

the map can be shown right,but the minimap is nothing in the map.

what should I do?

here is the code in my project:

XAML:

<telerik:RadMap x:Name="map"  Center="73.8737, -31.9043" ZoomLevel="7"  MinZoomLevel="3" MiniMapExpanderVisibility="Collapsed">
            <telerik:RadMap.Providers>
                <provider:MapProvider></provider:MapProvider>
            </telerik:RadMap.Providers>
</telerik:RadMap>

MapProvider :

public class MapProvider : TiledProvider
    {
        public MapProvider() : base()
        {
            MapSource mapSource = new MapSource();
            this.MapSources.Add(mapSource.UniqueId, mapSource);
        }
        public override ISpatialReference SpatialReference
        {
            get
            {
                return new MercatorProjection();
            }
        }
    }

 

MapSource:

public class MapSource : TiledMapSource
    {
        public override void Initialize()
        {
            RaiseIntializeCompleted();
        }

        public MapSource() : base(3, 18, 256, 256)
        {
        }

        protected override Uri GetTile(int tileLevel, int tilePositionX, int tilePositionY)
        {
            int zoomLevel = this.ConvertTileToZoomLevel(tileLevel);

            if (tilePositionY > Math.Pow(2, zoomLevel - 1) - 1)
            {
                return null;
            }

            string url = "http://www.arcgisonline.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer";
            
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat("{0}/tile/{1}/{2}/{3}", new object[] { url, zoomLevel - 1, tilePositionY, tilePositionX });

            return new Uri(builder.ToString());
        }
    }

 

and here is the result:

 

 

2 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 24 May 2016, 07:34 AM
Hi Wang,

Let me first start with that the Mini Map can use the first provider in provider list of parent RadMap control only. When you use a custom map provider with the mini map then you should implement the ICloneable interface. You can check the code snippet below.
ublic class MapProvider : TiledProvider, ICloneable
{
    /// ........
 
    public new object Clone()
    {
        MapProvider clone = new MapProvider();
 
        this.InheritCurrentSource(clone);
        this.InheritParameters(clone);
 
        return clone;
    }
}
In addition, you can check the Mini Map help article in our documentation for further information.
 
Hope this information was helpful.

Regards,
Dinko
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Wang
Top achievements
Rank 1
answered on 25 May 2016, 10:07 AM

Thank you very much! it worked fine!

Tags
Map
Asked by
Wang
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Wang
Top achievements
Rank 1
Share this question
or