private void Layers_LayerAdded(object sender, EventArgs e) { Layer lay = MapControl.AddLayer(); LayerItem item = new LayerItem(lay) { Text = "Untitled", Visible = true }; LayerEditor.Layers.AddItem(item); MapControl.RefreshLayers(); IsDirty = true; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { Defaults.Load(); _streets = OsmStreetSystem.LoadSystem("K:\\OsmData\\schleswig-holstein-latest.sn"); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here _map = new MapControl(spriteBatch, GraphicsDevice, GraphicsDevice.Viewport.Bounds.ToMapRectangle()); _map.Zoom = 15; _map.Position = new MapPointLatLon(53.8265376, 10.4917827); _map.ZoomMode = ZoomingType.Mouse; _routeLayer = _map.AddLayer(); _map.OnRightClick += _map_OnRightClick; }
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(); }
/// <summary> /// MainWindow /// </summary> public MainWindow() { InitializeComponent(); #region Subscribe to map events // Subscribe to mouse position change events and // show the current geo position below the map MapControl.GeoPositionChanged += (o, GeoPos) => GeoPositionTextBlock.Text = GeoPos.ToGeoString(); MapControl.MapViewChanged += (o, x, y, m) => DisplayOffsetTextBlock.Text = "Offset: " + x + " / " + y; #endregion #region Add map layers var _TilesLayer = MapControl.AddLayer <TilesLayer> ("TilesLayer", 0); var _ShapeLayerWG = MapControl.AddLayer <ShapeLayer> ("ShapeLayerWG", 10); var _ShapeLayerEG = MapControl.AddLayer <ShapeLayer> ("ShapeLayerEG", 11); var _HeatmapLayer = MapControl.AddLayer <HeatmapLayer> ("HeatmapLayer", 20); var _EditFeatureLayer = MapControl.AddLayer <EditFeatureLayer> ("EditFeatureLayer", 30, Visibility.Hidden); var _FeatureLayer = MapControl.AddLayer <FeatureLayer> ("FeatureLayer", 40); #endregion #region Add some features var feature1a = _FeatureLayer.AddFeature("ahzf", new Latitude(50.932253), new Longitude(11.625075), 5, 5, Colors.Red); var feature1b = _HeatmapLayer.AddFeature("ahzf", new Latitude(50.932253), new Longitude(11.625075), 150, 150, Colors.Red); var feature2a = _FeatureLayer.AddFeature("Hannover", new Latitude(52.373922), new Longitude(9.743500), 5, 5, Colors.Red); var feature2b = _HeatmapLayer.AddFeature("Hannover", new Latitude(52.373922), new Longitude(9.743500), 100, 100, Colors.Blue); var feature3a = _FeatureLayer.AddFeature("c-base", new Latitude(52.513191), new Longitude(13.420057), 5, 5, Colors.Red); var feature3b = _HeatmapLayer.AddFeature("c-base", new Latitude(52.513191), new Longitude(13.420057), 150, 150, Colors.Yellow); var feature4a = _FeatureLayer.AddFeature("malmö", new Latitude(55.618691), new Longitude(12.999573), 5, 5, Colors.Red); var feature4b = _HeatmapLayer.AddFeature("malmö", new Latitude(55.618691), new Longitude(12.999573), 50, 50, Colors.Brown); #endregion var efeature1a = _EditFeatureLayer.AddFeature("dfh", new Latitude(40.032253), new Longitude(7.025075), 5, 5, Colors.Green); #region Add some shapes //var feature5a = _ShapeLayerEG.AddShape(new Thueringen (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30))); var feature5b = _ShapeLayerWG.AddShape(new Bayern(Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30))); //var feature5c = _ShapeLayerWG.AddShape(new BadenWuerttemberg (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30))); //var feature5d = _ShapeLayerWG.AddShape(new Hessen (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30))); //var feature5e = _ShapeLayerWG.AddShape(new Saarland (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30))); //var feature5f = _ShapeLayerEG.AddShape(new Sachsen (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30))); //var feature5g = _ShapeLayerEG.AddShape(new SachsenAnhalt (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30))); //var feature5h = _ShapeLayerEG.AddShape(new Berlin (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30))); //var feature5i = _ShapeLayerWG.AddShape(new NordrheinWestfalen (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30))); //var feature5j = _ShapeLayerWG.AddShape(new RheinlandPfalz (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30))); //var feature5k = _ShapeLayerWG.AddShape(new Hamburg (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30))); //var feature5l = _ShapeLayerWG.AddShape(new Bremen (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30))); //var feature5m = _ShapeLayerEG.AddShape(new Brandenburg (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30))); //var feature5n = _ShapeLayerWG.AddShape(new SchleswigHolstein (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30))); //var feature5o = _ShapeLayerEG.AddShape(new MecklenburgVorpommern (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30))); //var feature5p = _ShapeLayerWG.AddShape(new Niedersachsen (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30))); #endregion // Set the deactivated style of the map search box MapSearchBox_LostFocus(this, null); // Set the initial focus on the map MapControl.Focus(); }