MapSources list in the "eye" button

2 posts, 0 answers
  1. Michele
    Michele avatar
    3 posts
    Member since:
    Jul 2012

    Posted 24 Mar 2015 Link to this post

    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!";
            }
        }

  2. Michele
    Michele avatar
    3 posts
    Member since:
    Jul 2012

    Posted 24 Mar 2015 in reply to Michele Link to this post

    I solved customizing the mapcommandbar

    http://docs.telerik.com/devtools/wpf/controls/radmap/how-to/howto-customize-commands.html
  3. DevCraft banner
Back to Top