MiniMap with custom provider

3 posts, 0 answers
  1. Wang
    Wang avatar
    42 posts
    Member since:
    Oct 2011

    Posted 19 May Link to this post

    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. Dinko
    Admin
    Dinko avatar
    206 posts

    Posted 24 May Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Wang
    Wang avatar
    42 posts
    Member since:
    Oct 2011

    Posted 25 May in reply to Dinko Link to this post

    Thank you very much! it worked fine!

Back to Top