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

MapSources list in the "eye" button

1 Answer 52 Views
Map
This is a migrated thread and some comments may be shown as answers.
Michele
Top achievements
Rank 1
Michele asked on 24 Mar 2015, 08:42 AM
Hi,

I developed a custom map provider with two mapsources (one for road and one for aerial maps): is there  a way to change the mapsource via the "eye" button of the map control? 

For example BingMapProvider has Aerial, Road, Bird's eye and so on shown when you click on the "eye" button, but when I set my custom MapProvider a see no  mapsource choice.

this is my code:

public class HereMapProvider : TiledProvider
    {

        
      
        /// <summary>
        /// Initializes a new instance of the MyMapProvider class.
        /// </summary>
        public HereMapProvider()
            : base()
        {
            HereMapSource source = new HereMapSource();
            this.MapSources.Add(source.UniqueId, source);
            HereAerialMapSource source1 = new HereAerialMapSource();
            this.MapSources.Add(source1.UniqueId, source1);
        }
        /// <summary>
        /// Returns the SpatialReference for the map provider.
        /// </summary>
        public override ISpatialReference SpatialReference
        {
            get
            {
                return new MercatorProjection();
            }
        }
    }


    public class HereAerialMapSource : TiledMapSource
    {
        /// <summary>
        /// Initializes a new instance of the MyMapSource class.
        /// </summary>
        public HereAerialMapSource()
            : base(1, 20, 256, 256)
        {
        }

     

        /// <summary>
        /// Initialize provider.
        /// </summary>
        public override void Initialize()
        {
            // Raise provider initialized event.
            this.RaiseIntializeCompleted();
        }
        /// <summary>
        /// Gets the image URI.
        /// </summary>
        /// <param name="tileLevel">Tile level.</param>
        /// <param name="tilePositionX">Tile X.</param>
        /// <param name="tilePositionY">Tile Y.</param>
        /// <returns>URI of image.</returns>
        protected override Uri GetTile(int tileLevel, int tilePositionX, int tilePositionY)
        {
            int zoomLevel = ConvertTileToZoomLevel(tileLevel);
            // Prepare tile url somehow ...

            string url = getUrl(zoomLevel, tilePositionX, tilePositionY);//CustomHelper.GetTileUrl(tileLevel, tilePositionX, tilePositionY);
            return new Uri(url);
        }

        private string getUrl(int tileLevel, int tilePositionX, int tilePositionY)
        {
            return @"http://1.aerial.maps.cit.api.here.com/maptile/2.1/basetile/newest/hybrid.day/" + tileLevel + "/" + tilePositionX + "/" + tilePositionY + "/256/png8?app_id=XXX&app_code=XXX&start=geo!";
        }
    }

    public class HereMapSource : TiledMapSource
    {

     

        /// <summary>
        /// Initializes a new instance of the MyMapSource class.
        /// </summary>
        public HereMapSource()
            : base(1, 20, 256, 256)
        {
        }


        /// <summary>
        /// Initialize provider.
        /// </summary>
        public override void Initialize()
        {
            // Raise provider initialized event.
            this.RaiseIntializeCompleted();
        }
        /// <summary>
        /// Gets the image URI.
        /// </summary>
        /// <param name="tileLevel">Tile level.</param>
        /// <param name="tilePositionX">Tile X.</param>
        /// <param name="tilePositionY">Tile Y.</param>
        /// <returns>URI of image.</returns>
        protected override Uri GetTile(int tileLevel, int tilePositionX, int tilePositionY)
        {
            int zoomLevel = ConvertTileToZoomLevel(tileLevel);
            // Prepare tile url somehow ...

            string url = getUrl(zoomLevel, tilePositionX, tilePositionY);//CustomHelper.GetTileUrl(tileLevel, tilePositionX, tilePositionY);
            return new Uri(url);
        }

        private string getUrl(int tileLevel, int tilePositionX, int tilePositionY)
        {
            return @"http://1.base.maps.cit.api.here.com/maptile/2.1/maptile/newest/normal.day/" + tileLevel + "/" + tilePositionX + "/" + tilePositionY + "/256/png8?app_id=XXX&app_code=XXX&start=geo!";
        }
    }

1 Answer, 1 is accepted

Sort by
0
Michele
Top achievements
Rank 1
answered on 24 Mar 2015, 09:34 AM
I solved customizing the mapcommandbar

http://docs.telerik.com/devtools/wpf/controls/radmap/how-to/howto-customize-commands.html
Tags
Map
Asked by
Michele
Top achievements
Rank 1
Answers by
Michele
Top achievements
Rank 1
Share this question
or