public void AddLayerTile(string url = "http://a.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png") { // Add MBTiles Layer. // any stream will do or any path on the device to a MBTiles SQLite databas // in this case the data is taken from the resource stream, written to disk and then opened. //map.AddLayer(new LayerMBTile(SQLiteConnection.CreateFrom( // Assembly.GetExecutingAssembly().GetManifestResourceStream(@"YOUR MB TILES FILE HERE"), "map"))); tileUrl = url; if (layerMap != null) { layerMap.Close(); } layerMap = map?.AddLayerTile(tileUrl); }
private void button_Click(object sender, RoutedEventArgs e) { //initialize map. var map = new OsmSharp.UI.Map.Map(new WebMercator()); // create the MapCSS image source. var imageSource = new MapCSSDictionaryImageSource(); // initialize mapcss interpreter. var mapCssInterpreter = new MapCSSInterpreter(File.OpenRead("data\\opencyclemap.mapcss"), imageSource); var source = new XmlOsmStreamSource(File.OpenRead("data\\test.osm")); var testLayer = new LayerOsm(MemoryDataSource.CreateFrom(source), mapCssInterpreter, new WebMercator()); // map.AddLayer(testLayer); map.AddLayerTile(@"http://b.tile.openstreetmap.org/{z}/{x}/{y}.png"); // map.BackColor = SimpleColor.FromKnownColor(OsmSharp.UI.KnownColor.Black).Value; MapControl.SuspendNotifyMapViewChanged(); // set control properties. MapControl.MapZoom = 14; MapControl.Map = map; MapControl.MapCenter = testLayer.Envelope.Center; // MapControl.MapCenter = new GeoCoordinate(51.2667, 4.7914); // wechel var l = new MapLayerWrapper(new WebMercator()); //l.AddPoint(testLayer.Envelope.Center, 20, SimpleColor.FromKnownColor(OsmSharp.UI.KnownColor.Black).Value); MapControl.AddLayer(l, 100); MapControl.ResumeNotifyMapViewChanged(); }