void InitialMapsByLocaltion(C1Maps maps, Location location) { C1VectorLayer layer = new C1VectorLayer(); Point center = new Point(); double zoom = 0; switch (location) { case Location.USA: Utils.LoadShapeFromResource(layer, "MapsSamples.Resources.states.shp", "MapsSamples.Resources.states.dbf", location, true, ProcessMap); center = new Point(-115, 50); zoom = 2; break; case Location.Japan: Utils.LoadShapeFromResource(layer, "MapsSamples.Resources.jp_toku_kuni_pgn.shp", "MapsSamples.Resources.jp_toku_kuni_pgn.dbf", location, true, ProcessMap); center = new Point(135, 37); zoom = 4; break; } if (maps.Layers != null && maps.Layers.Count != 0) { maps.Layers.Clear(); } maps.Layers.Add(layer); maps.MinZoom = zoom; maps.Zoom = zoom; maps.Center = center; }
private void OnMapsChanged(C1Maps oldMaps) { if (oldMaps != null) { oldMaps.ZoomChanged -= OnZoomChanged; oldMaps.CenterChanged -= OnCenterChanged; oldMaps.SizeChanged -= OnSizeChanged; } if (this.Maps != null) { this.Maps.ZoomChanged += OnZoomChanged; this.Maps.CenterChanged += OnCenterChanged; this.Maps.SizeChanged += OnSizeChanged; UpdateScale(); } }
public MapFilterPresenter() { _map = new C1Maps { Height = 200, Zoom = 2, Center = new Point(-83, 39), ShowTools = false, Source = new VirtualEarthRoadSource(), MinZoom = 2, MaxZoom = 2 }; _map.MouseDoubleClick += _map_MouseDoubleClick; _layer = new VectorLayer { LabelVisibility = LabelVisibility.Visible }; _map.Layers.Add(_layer); Items.Add(_map); }
public static void LoadKML(this C1VectorLayer vl, Stream stream, bool centerAndZoom, ProcessVectorItem processVector) { using (StreamReader sr = new StreamReader(stream)) { string s = sr.ReadToEnd(); List <C1VectorItemBase> vects = KmlReader.Read(s); vl.BeginUpdate(); foreach (C1VectorItemBase vect in vects) { if (processVector != null) { if (!processVector(vect)) { continue; } } vl.Children.Add(vect); } vl.EndUpdate(); if (centerAndZoom) { Rect bnds = vects.GetBounds(); C1Maps maps = ((IMapLayer)vl).ParentMaps; if (maps != null) { maps.Center = new Point(bnds.Left + 0.5 * bnds.Width, bnds.Top + 0.5 * bnds.Height); double scale = Math.Max(bnds.Width / 360 * maps.ActualWidth, bnds.Height / 180 * maps.ActualHeight);; double zoom = Math.Log(512 / scale, 2.0); maps.TargetZoom = maps.Zoom = zoom > 0 ? zoom : 0; } } sr.Close(); } }
void InitialMapsByLocaltion(C1Maps maps, Location location) { VectorLayer layer = null; if (maps.Layers.Count == 0) { layer = new VectorLayer(); maps.Layers.Add(layer); } else { layer = maps.Layers[0] as VectorLayer; layer.Children.Clear(); } Point center = new Point(); double zoom = 0; switch (location) { case Location.USA: Utils.LoadShapeFromResource(layer, "MapsExplorer.Resources.states.shp", "MapsExplorer.Resources.states.dbf", location, true, ProcessMap); center = new Point(-115, 50); zoom = 2; break; case Location.Japan: Utils.LoadShapeFromResource(layer, "MapsExplorer.Resources.jp_toku_kuni_pgn.shp", "MapsExplorer.Resources.jp_toku_kuni_pgn.dbf", location, true, ProcessMap); center = new Point(135, 37); zoom = 4; break; } maps.MinZoom = zoom; maps.Zoom = zoom; maps.Center = center; }
// returns the distance in meters from the center of the map to a point 'pixels' pixels to the right double GetDistance(double pixels) { return(C1Maps.Distance(Maps.Center, Maps.ScreenToGeographic(new Point( Maps.ActualWidth / 2 + pixels, Maps.ActualHeight / 2)))); }