Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        }     // End Sub Main

        private static Mapsui.Layers.MemoryLayer CreatePointLayer()
        {
            var random   = new System.Random();
            var features = new Mapsui.Providers.Features();

            for (var i = 0; i < 100; i++)
            {
                var feature = new Mapsui.Providers.Feature
                {
                    Geometry = new Mapsui.Geometries.Point(random.Next(100000, 5000000), random.Next(100000, 5000000))
                };
                features.Add(feature);
            } // Next i


            var provider = new Mapsui.Providers.MemoryProvider(features);

            return(new Mapsui.Layers.MemoryLayer {
                DataSource = provider
            });
        }