How do I add a new OpenStreetMapProvider (I.e. MapQuest)?

Topics: Feature Requests
Mar 6, 2012 at 3:13 PM
Edited Mar 6, 2012 at 3:35 PM

Hello,

I'm currently trying to implement a map in my C#/WPF application. Per OpenStreetMaps request, I would like to use the MapQuest tileserver for the tiles: http://developer.mapquest.com/web/products/open/map

I tried implementing a new OpenStreetMapProvider, how do use or instanciate the class MapQuestProvider now?

 

public class MapQuestProvider : OpenStreetMapProviderBase
    {
            public static readonly MapQuestProvider Instance;

            MapQuestProvider()
            {
            }

            static MapQuestProvider()
            {
                Instance = new MapQuestProvider();
            }

            readonly Guid _Id = new Guid("D0A12840-973A-448B-B9C2-89B8A07DFF0F");
            public override Guid Id
            {
                get
                {
                    return _Id;
                }
            }

            readonly string _Name = "MapQuest";
            public override string Name
            {
                get
                {
                    return _Name;
                }
            }

            GMapProvider[] _Overlays;
            public override GMapProvider[] Overlays
            {
                get
                {
                    if (_Overlays == null)
                    {
                        _Overlays = new GMapProvider[] { this };
                    }
                    return _Overlays;
                }
            }

            public override PureImage GetTileImage(GPoint pos, int zoom)
            {
                string url = MakeTileImageUrl(pos, zoom, string.Empty);

                return GetTileImageUsingHttp(url);
            }

            string MakeTileImageUrl(GPoint pos, int zoom, string language)
            {
                return string.Format(UrlFormat, zoom, pos.X, pos.Y);
            }

            static readonly string UrlFormat = "http://otile1.mqcdn.com/tiles/1.0.0/osm/{0}/{1}/{2}.png";
        }
Coordinator
Mar 6, 2012 at 3:25 PM

map.MapProvider = MapQuestProvider.Instance

Mar 6, 2012 at 3:35 PM

Ah, thank you. I was trying to instanciate it myself...

Coordinator
Aug 24, 2012 at 11:53 AM

this provider is now included by default