ThinkGeo.com    |     Documentation    |     Premium Support

OpenStreetMapLayer map type

Hi, how do I set OpenStreetMapLayer map type? It doesnt have such propertie like bingMapLayer or googleMapsLayer (I need to use them because I need getBitmap method). So how do I set OpenStreetMapLayer type?

Hi Hotter,



The OpenStreetMapLayer doesn’t include the “MapType”, this property is only in OpenStreetMapOverlay. But here is an opinion for the OpenStreetMapLayer :


Uri[] DefaultUris = { 
                                        new Uri("<a href=“a.tile.openstreetmap.org/">a.tile.openstreetmap.org/</a>{0}/{1}/{2}.png"), 
                                        new Uri(”<a href=“b.tile.openstreetmap.org/">b.tile.openstreetmap.org/</a>{0}/{1}/{2}.png"), 
                                        new Uri(”<a href=“c.tile.openstreetmap.org/">c.tile.openstreetmap.org/</a>{0}/{1}/{2}.png"
                                    };
 
                Uri[] MapQuestOpenUris = { 
                                        new Uri(”<a href=“otile1.mqcdn.com/tiles/1.0.0/osm/">otile1.mqcdn.com/tiles/1.0.0/osm/</a>{0}/{1}/{2}.png"), 
                                        new Uri(”<a href=“otile2.mqcdn.com/tiles/1.0.0/osm/">otile2.mqcdn.com/tiles/1.0.0/osm/</a>{0}/{1}/{2}.png"), 
                                        new Uri(”<a href=“otile3.mqcdn.com/tiles/1.0.0/osm/">otile3.mqcdn.com/tiles/1.0.0/osm/</a>{0}/{1}/{2}.png"
                                    };
                Uri[] CycleMapUris = { 
                                        new Uri(”<a href=“a.tile.opencyclemap.org/cycle/">a.tile.opencyclemap.org/cycle/</a>{0}/{1}/{2}.png"), 
                                        new Uri(”<a href=“a.tile.opencyclemap.org/cycle/">a.tile.opencyclemap.org/cycle/</a>{0}/{1}/{2}.png"), 
                                        new Uri(”<a href="a.tile.opencyclemap.org/cycle/">a.tile.opencyclemap.org/cycle/</a>{0}/{1}/{2}.png"
                                    };
                OpenStreetMapLayer osm = new OpenStreetMapLayer();
                foreach (var item in CycleMapUris)
                {
                    osm.CustomServerUris.Add(item);
                }
 

LayerOverlay staticOverlay = new LayerOverlay(“osm”);
                staticOverlay.IsBaseOverlay = false;
                staticOverlay.Layers.Add(osm);
                Map1.CustomOverlays.Add(staticOverlay);

Thanks,

Troy

Thanks, but I get error "(404) Not Found.".

Hi Hotter,



I tested it again, but I didn’t encounter this issue. Do you mean all the three OSM type are have an 404 issue or only happened in CircleMap? Could you click the below links to see if you can access them in your browser?

c.tile.opencyclemap.org/cycle/5/7/11.png

otile2.mqcdn.com/tiles/1.0.0/osm/5/5/10.png



Also, you can register the SendingWebRequest event on OpenStreetMapLayer and then check the request uri in its events handler parameter.


OpenStreetMapLayer osm = new OpenStreetMapLayer();
                osm.SendingWebRequest += osm_SendingWebRequest;

        void osm_SendingWebRequest(object sender, SendingWebRequestEventArgs e)
        {
            string requestTileUri = (e.WebRequest).RequestUri.AbsoluteUri;
        }

I am guessing if your internet can’t access the map service opencyclemap.org and mqcdn.com.

Let me know if the issue persists.

Thanks,

Troy

Hi, thanks for answer, yes I can click on those links it ok. 
 I added SendingWebRequest and AbsoluteUri is: 
 otile1.mqcdn.com/tiles/1.0.0/osm/{0}/{1}/{2}.png/6/17/26.png 
 I changed uri to this: 
 Uri[] MapQuestOpenUris = { new Uri("otile1.mqcdn.com/tiles/1.0.0/osm"), new Uri("otile2.mqcdn.com/tiles/1.0.0/osm"), new Uri("otile3.mqcdn.com/tiles/1.0.0/osm") }; 
 And it works, thank you very much.

Hi HOtter, 
  
 Glad to hear it works. 
 Any other questions, please feel free to let us know. 
  
 Thanks, 
 Troy