Exemplo n.º 1
0
        void AddSources(List <ShapeSource> sources)
        {
            if (sources == null || map == null)
            {
                return;
            }

            foreach (ShapeSource ss in sources)
            {
                if (ss.Id != null && ss.Shape != null)
                {
                    var shape = ss.Shape.ToFeatureCollection();

                    var source = map.GetSource(ss.Id.Prefix()) as Sdk.Style.Sources.GeoJsonSource;

                    if (source == null)
                    {
                        source = new Sdk.Style.Sources.GeoJsonSource(ss.Id.Prefix(), shape);
                        map.AddSource(source);
                    }
                    else
                    {
                        source.SetGeoJson(shape);
                    }
                }
            }
        }
        void AddSources(List <MapSource> sources)
        {
            if (sources == null || map == null)
            {
                return;
            }

            foreach (MapSource mapSource in sources)
            {
                if (mapSource.Id != null)
                {
                    if (mapSource is ShapeSource shapeSource && shapeSource.Shape != null)
                    {
                        var shape = shapeSource.Shape.ToFeatureCollection();

                        var source = map.GetSource(shapeSource.Id.Prefix()) as Sdk.Style.Sources.GeoJsonSource;

                        if (source == null)
                        {
                            source = new Sdk.Style.Sources.GeoJsonSource(shapeSource.Id.Prefix(), shape);
                            map.AddSource(source);
                        }
                        else
                        {
                            source.SetGeoJson(shape);
                        }
                    }
                    else if (mapSource is RasterSource rs)
                    {
                        var source = map.GetSource(rs.Id);
                        if (source == null)
                        {
                            Sdk.Style.Sources.RasterSource rasterSource = new Sdk.Style.Sources.RasterSource(rs.Id, rs.ConfigurationURL, (int)rs.TileSize);
                            map.AddSource(rasterSource);
                        }
                    }
                }
            }