private Mapsui.Layers.MemoryLayer GetLabelLayer(Dictionary <MapPinType, MapPinCollection> worldpindata) { Mapsui.Layers.MemoryLayer _pointlayer = new Mapsui.Layers.MemoryLayer { Style = null }; List <Mapsui.Geometries.Point> _points = new List <Mapsui.Geometries.Point>(); MapPinType pintype = worldpindata.Keys.ToList().Where(item => item.InternalName == "RoadSign").FirstOrDefault(); string path = Path.Combine(appdir, largeiconpath, pintype.IconFile); var memoryProvider = new Mapsui.Providers.MemoryProvider(); //Load the image if needed if (!IconCache.ContainsKey(path)) { using (FileStream fs = new FileStream(path, FileMode.Open)) { MemoryStream ms = new MemoryStream(); fs.CopyTo(ms); int id = BitmapRegistry.Instance.Register(ms); IconCache[path] = id; } } foreach (MapPin c in worldpindata[pintype].Locations) { var feature = new Mapsui.Providers.Feature { Geometry = CurrentConvertor.ToWorldSpace(c.Location), }; feature.Styles.Add(new LabelStyle { Text = BreakLines(c.Name, 17), ForeColor = Color.White, BackColor = new Brush(Color.Gray), Halo = new Pen(Color.Black, 2), VerticalAlignment = LabelStyle.VerticalAlignmentEnum.Bottom, Offset = new Offset(0, 14), CollisionDetection = false }); feature.Styles.Add(new SymbolStyle { BitmapId = IconCache[path] }); memoryProvider.Features.Add(feature); } _pointlayer.DataSource = memoryProvider; return(_pointlayer); }
public MarkerViewModel(MapPinType pintype, Mapsui.Layers.MemoryLayer layer) { Name = pintype.InternalName; Text = pintype.Name; _layer = layer; Children = new List <MarkerViewModel>(); _isChecked = _layer.Enabled; _smallIconName = pintype.IconFile; if (Properties.Settings.Default.MarkersState.ContainsKey(Name)) { _isChecked = _layer.Enabled = bool.Parse(Properties.Settings.Default.MarkersState[Name]); } else { Properties.Settings.Default.MarkersState.Add(Name, _isChecked.ToString()); } Properties.Settings.Default.Save(); }