private void ResetLayers() { _layers.Clear(); _c1maps.Layers.Clear(); foreach (LayerBase l in _owner.Layers.FindAllReverse((ll) => ll.Visible)) { MapsLayerBase layer; if (l is PointsLayer) { layer = new PointsMapsLayer(l); } else if (l is LinesLayer) { layer = new LinesMapsLayer(l); } else if (l is KmlLayer) { layer = new KmlMapsLayer(l); } else { System.Diagnostics.Debug.Assert(false, "unknown map layer type"); layer = null; } _layers.Add(layer); _c1maps.Layers.Add(layer.Layer); } }
/// <summary> /// Adds a point. /// </summary> /// <param name="layerKey"></param> /// <param name="longitude"></param> /// <param name="latitude"></param> /// <param name="caption"></param> /// <param name="font"></param> /// <param name="markShape"></param> /// <param name="size"></param> /// <param name="stroke"></param> /// <param name="fill"></param> public void DrawPoint(string layerKey, double longitude, double latitude, string caption, System.Drawing.Font font, System.Drawing.Color textColor, MarkerShape markShape, double size, System.Drawing.Color stroke, System.Drawing.Color fill) { #if !DYN var mark = new C1.WPF.Maps.C1VectorPlacemark(); mark.Lod = new C1.WPF.Maps.LOD(1, 300, 0, 10); // tbd: allow to control this #else dynamic mark = DynLoader.CreateC1MapsInstance("C1VectorPlacemark"); mark.Lod = DynLoader.CreateC1MapsInstance("C1.WPF.Maps.LOD", 1, 300, 0, 10); #endif mark.GeoPoint = new Point(longitude, latitude); if (!string.IsNullOrEmpty(caption)) { mark.Label = caption; Util.ApplyFontToControl(font, mark); if (!Util.IsColorEmpty(textColor)) { mark.Foreground = Util.BrushFromGdiColor(textColor); } // mark.LabelPosition = WPF.Maps.LabelPosition.Right | WPF.Maps.LabelPosition.Bottom; // mark.Background = new SolidColorBrush(Colors.Red); // TBD: label: // - setting mark.LabelPosition makes the label tiny. clarify. } mark.Geometry = Util.MarkerShapeToGeometry(markShape, size); mark.Stroke = Util.BrushFromGdiColor(stroke); mark.Fill = Util.BrushFromGdiColor(fill); PointsMapsLayer ml = _layers.Find((l) => l.MapLayer.Key == layerKey) as PointsMapsLayer; System.Diagnostics.Debug.Assert(ml != null); ml.AddMark(mark); }