コード例 #1
0
        async void btnChangeLanguage_Clicked(object sender, EventArgs e)
        {
            var dictionary = new Dictionary <string, string> {
                { "English", "name_en" },
                { "French", "name_fr" },
                { "Russian", "name_ru" },
                { "German", "name_de" },
                { "Spanish", "name_es" }
            };

            var selectedLanguage = await DisplayActionSheet(
                "Change language",
                "Cancel",
                null,
                dictionary.Keys.ToArray()
                );

            if (dictionary.TryGetValue(selectedLanguage, out var mapLanguage))
            {
                var layer = new SymbolLayer("country-label", "built-in")
                {
                    TextField = Expression.Get(mapLanguage)
                };

                btnChangeLanguage.Text = selectedLanguage;
                map.Functions.UpdateLayer(layer);
            }
        }
コード例 #2
0
        private void HandleStyleLoaded(MapStyle obj)
        {
            var source = new GeoJsonSource(GEOJSON_SRC_ID, "asset://poi_places.geojson")
            {
                IsLocal = true
            };

            map.Functions.AddSource(source);

            var layer = new SymbolLayer(POI_LABELS_LAYER_ID, GEOJSON_SRC_ID)
            {
                TextField          = Expression.Get("description"),
                TextSize           = 17f,
                TextColor          = Color.Red,
                TextVariableAnchor = new []
                {
                    LayerProperty.TEXT_ANCHOR_TOP,
                    LayerProperty.TEXT_ANCHOR_BOTTOM,
                    LayerProperty.TEXT_ANCHOR_LEFT,
                    LayerProperty.TEXT_ANCHOR_RIGHT
                },
                TextJustify      = LayerProperty.TEXT_JUSTIFY_AUTO,
                TextRadialOffset = 0.5f
            };

            map.Functions.AddLayer(layer);
        }
コード例 #3
0
        /// <summary>
        /// NOTE: According to documentation, as of the moment, the icon-rotation-alignment does not support data-driven-styling yet
        /// https://www.mapbox.com/mapbox-gl-js/style-spec/#layout-symbol-icon-rotation-alignment
        /// </summary>
        private void initializePinsLayer()
        {
            // Pins with bearings layer - configure elements
            var mapLockedPinsPropertyValues = new List <PropertyValue> {
                PropertyFactory.IconImage("{" + pin_image_key + "}"),             //Tokenize the field
                PropertyFactory.IconRotate(Expression.Get(pin_rotation_key)),
                PropertyFactory.IconSize(Expression.Get(pin_size_key)),
                PropertyFactory.IconRotationAlignment("map"),                 // Finally the map-lock flat = "map"
                PropertyFactory.IconAllowOverlap(Java.Lang.Boolean.True)      // Always overlap
            };
            var mapLockedPinsLayer = new SymbolLayer(mapLockedPinsKey, mapLockedPinsSourceKey)
                                     .WithProperties(mapLockedPinsPropertyValues.ToArray());

            nMap.AddLayer(mapLockedPinsLayer);

            // Normal pins layer - configure elements
            var normalPinsPropertyValues = new List <PropertyValue> {
                PropertyFactory.IconImage("{" + pin_image_key + "}"),       //Tokenize the field
                PropertyFactory.IconSize(Expression.Get(pin_size_key)),
                PropertyFactory.IconOffset(Expression.Get(pin_offset_key)), //https://www.mapbox.com/mapbox-gl-js/style-spec/#layout-symbol-icon-offset
                PropertyFactory.IconAnchor("bottom"),                       // https://www.mapbox.com/mapbox-gl-js/style-spec/#layout-symbol-icon-anchor = "bottom" or "center"
                PropertyFactory.IconAllowOverlap(Java.Lang.Boolean.True)    // Always overlap
            };
            var normalPinsLayer = new SymbolLayer(normalPinsKey, normalPinsSourceKey)
                                  .WithProperties(normalPinsPropertyValues.ToArray());

            nMap.AddLayer(normalPinsLayer);
        }
コード例 #4
0
        private void SelectState(string stateName, int stateIndex)
        {
            if (IndexOfState(stateName) == stateIndex)
            {
                // Adds a SymbolLayer to display maximum temperature in state
                SymbolLayer maxTempLayer = new SymbolLayer(MAX_TEMP_LAYER_ID, GEOJSON_SRC_ID)
                {
                    Filter = Expression.All(
                        Expression.Eq(Expression.Get("element"), ("All-Time Maximum Temperature")),
                        Expression.Eq(Expression.Get("state"), (stateName))
                        )
                };
                map.Functions.UpdateLayer(maxTempLayer);

                // Adds a SymbolLayer to display minimum temperature in state
                SymbolLayer minTempLayer = new SymbolLayer(MIN_TEMP_LAYER_ID, GEOJSON_SRC_ID)
                {
                    Filter = (Expression.All(
                                  Expression.Eq(Expression.Get("element"), ("All-Time Minimum Temperature")),
                                  Expression.Eq(Expression.Get("state"), (stateName))))
                };
                map.Functions.UpdateLayer(minTempLayer);

                var cameara = new CameraBounds(states[stateIndex].bounds, 100);
                map.Functions.AnimateCamera(cameara, 100);
            }
        }
コード例 #5
0
        public void Should_HaveDefaultId()
        {
            var layer = new SymbolLayer();

            Assert.NotEmpty(layer.Id);
            Assert.Equal(LayerType.SymbolLayer, layer.Type);
            Assert.Empty(layer.EventActivationFlags.EnabledEvents);
        }
コード例 #6
0
        private void HandleStyleLoaded(MapStyle obj)
        {
            map.Center = new LatLng(double.Parse((this.BindingContext as CalculateViewModel).Lat),
                                    double.Parse((this.BindingContext as CalculateViewModel).Lon));

            iconImageSource   = (ImageSource)"RE.png";
            markerImageSource = (ImageSource)"Marker.png";

            map.Functions.AddStyleImage(iconImageSource);
            map.Functions.AddStyleImage(markerImageSource);

            featureCollection = new FeatureCollection(symbolLayerIconFeatureList);
            markerCollection  = new FeatureCollection(markerLayerIconFeatureList);

            source = new GeoJsonSource
            {
                Id   = "feature.memory.src",
                Data = featureCollection
            };

            markerSource = new GeoJsonSource
            {
                Id   = "feature.marker.src",
                Data = markerCollection
            };

            map.Functions.AddSource(source);
            map.Functions.AddSource(markerSource);

            symbolLayer = new SymbolLayer("feature.symbol.layer", source.Id)
            {
                IconAllowOverlap = Expression.Literal(true),
                IconImage        = Expression.Literal(iconImageSource.Id),
                IconOffset       = Expression.Literal(new[] { -5, -5 }),
                IconSize         = Expression.Literal(0.7)
            };

            markerLayer = new SymbolLayer("feature.marker.layer", markerSource.Id)
            {
                IconAllowOverlap = Expression.Literal(true),
                IconImage        = Expression.Literal(markerImageSource.Id),
                IconOffset       = Expression.Literal(new[] { -5, -5 }),
                IconSize         = Expression.Literal(0.2)
            };

            map.Functions.AddLayer(symbolLayer);
            map.Functions.AddLayer(markerLayer);

            var feature = new Feature(new GeoJSON.Net.Geometry.Point(new Position(
                                                                         (this.BindingContext as CalculateViewModel).Lat,
                                                                         (this.BindingContext as CalculateViewModel).Lon)));

            symbolLayerIconFeatureList.Add(feature);
            featureCollection = new FeatureCollection(symbolLayerIconFeatureList);

            map.Functions.UpdateSource(source.Id, featureCollection);
        }
コード例 #7
0
        public void Should_HaveGivenId()
        {
            const string id    = "id";
            var          layer = new SymbolLayer(id);

            Assert.Equal(id, layer.Id);
            Assert.Equal(LayerType.SymbolLayer, layer.Type);
            Assert.Empty(layer.EventActivationFlags.EnabledEvents);
        }
コード例 #8
0
        public static Sdk.Style.Layers.SymbolLayer ToNative(this SymbolLayer symbol)
        {
            if (symbol == null)
            {
                return(null);
            }
            var native = new Sdk.Style.Layers.SymbolLayer(symbol.Id, symbol.SourceId);

            return(native);
        }
コード例 #9
0
        public static SymbolLayer ToForms(this Sdk.Style.Layers.SymbolLayer symbol)
        {
            if (symbol == null)
            {
                return(null);
            }
            var forms = new SymbolLayer(symbol.Id, "");

            return(forms);
        }
コード例 #10
0
        public void Should_TriggerLayerAdded()
        {
            var layer     = new SymbolLayer();
            var triggered = false;
            var map       = new Map("id");
            var eventArgs = new MapJsEventArgs {
                Type = "layeradded"
            };

            layer.OnLayerAdded += args => triggered = args.Map == map && args.Type == eventArgs.Type;
            layer.DispatchEvent(map, eventArgs);
            Assert.True(triggered);
        }
コード例 #11
0
        StyleLayer CreateStyleLayer(MGLVectorStyleLayer vectorLayer, string layerId = null)
        {
            if (vectorLayer is MGLSymbolStyleLayer sl && sl.IconImageName != null)
            {
                var newLayer = new SymbolLayer(layerId ?? vectorLayer.Identifier, vectorLayer.SourceIdentifier.TrimCustomId());
                if (sl.IconImageName is MGLCameraStyleFunction csFunc)
                {
                    var imgName = GetValueFromCameraStyleFunction(csFunc);
                    if (imgName != null)
                    {
                        newLayer.IconImageName = imgName.ToString();
                    }
                }
                else
                {
                    var imgName = GetObjectFromStyleValue(sl.IconImageName);
                    if (imgName != null)
                    {
                        newLayer.IconImageName = imgName.ToString();
                    }
                }
                return(newLayer);
            }

            if (vectorLayer is MGLLineStyleLayer ll)
            {
                var newLayer = new LineLayer(layerId ?? vectorLayer.Identifier, vectorLayer.SourceIdentifier.TrimCustomId())
                {
                    LineColor = (GetObjectFromStyleValue(ll.LineColor) as UIColor).ToColor()
                };

                if (ll.LineDashPattern != null)
                {
                    if (GetObjectFromStyleValue(ll.LineDashPattern) is NSArray arr && arr.Count != 0)
                    {
                        var dash = new List <double>();
                        for (nuint i = 0; i < arr.Count; i++)
                        {
                            var obj = arr.GetItem <NSNumber>(i);
                            dash.Add(obj.DoubleValue);
                        }
                        newLayer.Dashes = dash.ToArray();
                    }
                    else
                    {
                        //TODO
                    }
                }
                return(newLayer);
            }
コード例 #12
0
        /**
         * Adds a SymbolLayer to display the depth of the lake's areas
         */
        private void SetUpDepthNumberSymbolLayer()
        {
            var depthNumberSymbolLayer = new SymbolLayer("DEPTH_NUMBER_SYMBOL_LAYER_ID",
                                                         GEOJSON_SOURCE_ID)
            {
                TextField        = Expression.Get("depth"),
                TextSize         = 17f,
                TextColor        = Color.White,
                TextAllowOverlap = true
            };

            // Only display Point Features in this layer
            depthNumberSymbolLayer.Filter = Expression.Eq(Expression.GeometryType(), Expression.Literal("Point"));

            map.Functions.AddLayerAbove(depthNumberSymbolLayer, "DEPTH_POLYGON_FILL_LAYER_ID");
        }
コード例 #13
0
ファイル: StartPage.xaml.cs プロジェクト: HankiDesign/MovePal
        private void HandleStyleLoaded(MapStyle obj)
        {
            var fillExtrusionLayer = new FillExtrusionLayer("3d-buildings", "composite")
            {
                SourceLayer         = "building",
                Filter              = Expression.Eq(Expression.Get("extrude"), "true"),
                MinZoom             = 10,
                FillExtrusionColor  = Color.LightGray,
                FillExtrusionHeight = Expression.Interpolate(
                    Expression.Exponential(1f),
                    Expression.Zoom(),
                    Expression.CreateStop(15, (0)),
                    Expression.CreateStop(16, Expression.Get("height"))
                    ),
                FillExtrusionBase    = Expression.Get("min_height"),
                FillExtrusionOpacity = 0.9f
            };

            //map.Functions.AddLayer(fillExtrusionLayer);

            map.Functions.AnimateCamera(map.Camera, 1000);

            iconImageSource = (ImageSource)"RE.png";
            map.Functions.AddStyleImage(iconImageSource);

            featureCollection = new FeatureCollection(symbolLayerIconFeatureList);

            source = new GeoJsonSource
            {
                Id   = "feature.memory.src",
                Data = featureCollection
            };

            map.Functions.AddSource(source);

            symbolLayer = new SymbolLayer("feature.symbol.layer", source.Id)
            {
                IconAllowOverlap = Expression.Literal(true),
                IconImage        = Expression.Literal(iconImageSource.Id),
                IconOffset       = Expression.Literal(new[] { -5, -5 }),
                IconSize         = Expression.Literal(0.7)
            };

            map.Functions.AddLayer(symbolLayer);

            map.DidTapOnMapCommand = new Command <(LatLng position, Point point)>(HandleMapTapped);
        }
コード例 #14
0
                    public static SymbolLayer FromBaseObject(BaseObject baseObj)
                    {
                        if (baseObj == null || baseObj.NativeObject == IntPtr.Zero)
                        {
                            return(null);
                        }
                        SymbolLayer obj = baseObj as  SymbolLayer;

                        if (object.Equals(obj, null))
                        {
                            obj = new SymbolLayer(CreatedWhenConstruct.CWC_NotToCreate);
                            obj.BindNativeObject(baseObj.NativeObject, "CSymbolLayer");
                            obj.IncreaseCast();
                        }

                        return(obj);
                    }
コード例 #15
0
        public void Should_TriggerDblClick()
        {
            var layer     = new SymbolLayer();
            var triggered = false;
            var map       = new Map("id");
            var eventArgs = CreateEventArgsForMouseEvent("dblclick");

            layer.OnDblClick += args => {
                triggered = args.Map == map &&
                            args.LayerId == eventArgs.LayerId &&
                            args.Pixel == eventArgs.Pixel &&
                            args.Position == eventArgs.Position

                            && args.Type == eventArgs.Type;
            };
            layer.DispatchEvent(map, eventArgs);
            Assert.True(triggered);
        }
コード例 #16
0
        void HandleStyleLoaded(MapStyle obj)
        {
            var fisrtPoint = lineString.Coordinates[0];

            map.Center = new LatLng(fisrtPoint.Latitude, fisrtPoint.Longitude);

            IconImageSource icon = (ImageSource)"pink_dot.png";

            map.Functions.AddStyleImage(icon);

            map.Functions.AddSource(new GeoJsonSource()
            {
                Id   = lineSourceId,
                Data = new FeatureCollection()
            });
            var routeLayer = new LineLayer("trip.layer", lineSourceId)
            {
                LineColor = Expression.Color(Color.FromHex("#F13C6E")),
                LineCap   = Expression.Literal("round"),
                LineJoin  = Expression.Literal("round"),
                LineWidth = Expression.Literal(4.0f)
            };

            map.Functions.AddLayerBelow(routeLayer, "road-label");

            map.Functions.AddSource(new GeoJsonSource()
            {
                Id   = dotSourceId,
                Data = new Feature(new GeoJSON.Net.Geometry.Point(fisrtPoint))
            });

            var dotLayer = new SymbolLayer("dot.layer", dotSourceId)
            {
                IconImage           = Expression.Literal(icon.Id),
                IconSize            = Expression.Literal(0.5f),
                IconOffset          = Expression.Literal(new[] { 5, 0 }),
                IconIgnorePlacement = Expression.Literal(true),
                IconAllowOverlap    = Expression.Literal(true)
            };

            map.Functions.AddLayer(dotLayer);

            Animate();
        }
コード例 #17
0
        public void Should_TriggerTouchStart()
        {
            var layer     = new SymbolLayer();
            var triggered = false;
            var map       = new Map("id");
            var eventArgs = CreateEventArgsForTouchEvent("touchstart");

            layer.OnTouchStart += args => {
                triggered = args.Map == map &&
                            args.LayerId == eventArgs.LayerId &&
                            args.Pixel == eventArgs.Pixel &&
                            args.Position == eventArgs.Position

                            && args.Pixels == eventArgs.Pixels &&
                            args.Positions == eventArgs.Positions &&
                            args.Type == eventArgs.Type;
            };
            layer.DispatchEvent(map, eventArgs);
            Assert.True(triggered);
        }
コード例 #18
0
        private void InitializeMap()
        {
            MyMap.MapLoaded += () =>
            {
                isMapLoaded = true;

                hospitalLayer = new SymbolLayer()
                {
                    Source  = new GeoJsonSource(),
                    Options = new SymbolOptions
                    {
                        IconImage = "pin-blue"
                    }
                };
                MyMap.Layers.Add(hospitalLayer);

                LoadMapDataForImage();
            };

            //Set the Azure Maps subscription key, this will trigger the MapLoaded event once the map is initially rendered.
            MyMap.SubscriptionKey = AzureMapsSubscriptionKey;
        }
コード例 #19
0
        private void ChangeTemperatureUnits(bool v)
        {
            if (this.isImperial != v)
            {
                this.isImperial = v;

                // Apply new units to the data displayed in text fields of SymbolLayers
                var maxTempLayer = new SymbolLayer(MAX_TEMP_LAYER_ID, GEOJSON_SRC_ID)
                {
                    TextField = (GetTemperatureValue())
                };
                map.Functions.UpdateLayer(maxTempLayer);

                var minTempLayer = new SymbolLayer(MIN_TEMP_LAYER_ID, GEOJSON_SRC_ID)
                {
                    TextField = (GetTemperatureValue())
                };
                map.Functions.UpdateLayer(minTempLayer);

                unitsText.Text = (v ? DEGREES_C : DEGREES_F);
            }
        }
コード例 #20
0
        private async void ShowTrapsOnMap(List <System.Windows.Point> pixels)
        {
            if (pixels != null && pixels.Count > 0 && imagePosition != null && imagePosition.Count > 0)
            {
                var pins = new List <GeoPoint>();

                var topLeftPixel = await MyMap.PositionToPixel(imagePosition[0]);

                //Calculate approximate pixel coordinates. Since images cover small areas we can use linear approximations.
                var imageWidth  = img.Width;
                var imageHeight = img.Height;

                var west = imagePosition[0].Longitude;
                var dLng = imagePosition[2].Longitude - west;

                var north = imagePosition[0].Latitude;
                var dLat  = north - imagePosition[2].Latitude;

                if (topLeftPixel != null && topLeftPixel.HasValue)
                {
                    foreach (var p in pixels)
                    {
                        pins.Add(new GeoPoint(new Position(west + (p.X / imageWidth) * dLng, north - (p.Y / imageHeight) * dLat)));
                    }

                    trapLayer = new SymbolLayer()
                    {
                        Source  = new GeoJsonSource(),
                        Options = new SymbolOptions
                        {
                            IconImage = "pin-round-red"
                        }
                    };
                    (trapLayer.Source as GeoJsonSource).AddRange(pins);
                    MyMap.Layers.Add(trapLayer);
                }
            }
        }
コード例 #21
0
        private void InitTemperatureLayers()
        {
            // Adds a SymbolLayer to display maximum temperature in state
            var maxTempLayer = new SymbolLayer(MAX_TEMP_LAYER_ID, GEOJSON_SRC_ID)
            {
                IconImage           = (RED_PIN_IMAGE_ID),
                TextField           = (GetTemperatureValue()),
                TextSize            = (17f),
                TextOffset          = (new float[] { 0f, -1.75f }),
                TextColor           = (Color.Red),
                TextAllowOverlap    = (true),
                TextIgnorePlacement = (true),
                IconAllowOverlap    = (true),
                IconIgnorePlacement = (true),
                Filter = (Expression.Eq(Expression.Get("element"), Expression.Literal("All-Time Maximum Temperature")))
            };

            map.Functions.AddLayer(maxTempLayer);

            // Adds a SymbolLayer to display minimum temperature in state
            var minTempLayer = new SymbolLayer(MIN_TEMP_LAYER_ID, GEOJSON_SRC_ID)
            {
                IconImage           = BLUE_PIN_IMAGE_ID,
                TextField           = GetTemperatureValue(),
                TextSize            = 17f,
                TextOffset          = (new float[] { 0f, -2.5f }),
                TextColor           = Color.Blue,
                TextAllowOverlap    = true,
                TextIgnorePlacement = true,
                IconAllowOverlap    = true,
                IconIgnorePlacement = true,
                Filter = Expression.Eq(Expression.Get("element"), Expression.Literal("All-Time Minimum Temperature"))
            };

            map.Functions.AddLayer(minTempLayer);

            unitsText.Text = (isImperial ? DEGREES_C : DEGREES_F);
        }
コード例 #22
0
        void HandleStyleLoaded(MapStyle obj)
        {
            IconImageSource iconImageSource = (ImageSource)"red_marker.png";

            map.Functions.AddStyleImage(iconImageSource);

            var symbolLayerIconFeatureList = new List <Feature>();

            symbolLayerIconFeatureList.Add(
                new Feature(new GeoJSON.Net.Geometry.Point(
                                new GeoJSON.Net.Geometry.Position(-33.213144, -57.225365))));
            symbolLayerIconFeatureList.Add(
                new Feature(new GeoJSON.Net.Geometry.Point(
                                new GeoJSON.Net.Geometry.Position(-33.981818, -54.14164))));
            symbolLayerIconFeatureList.Add(
                new Feature(new GeoJSON.Net.Geometry.Point(
                                new GeoJSON.Net.Geometry.Position(-30.583266, -56.990533))));

            var featureCollection = new FeatureCollection(symbolLayerIconFeatureList);

            var source = new GeoJsonSource
            {
                Id   = "feature.memory.src",
                Data = featureCollection
            };

            map.Functions.AddSource(source);

            var symbolLayer = new SymbolLayer("feature.symbol.layer", source.Id)
            {
                IconAllowOverlap = Expression.Literal(true),
                IconImage        = Expression.Literal(iconImageSource.Id),
                IconOffset       = Expression.Literal(new[] { 0.0, -9.0 })
            };

            map.Functions.AddLayer(symbolLayer);
        }
コード例 #23
0
        private void AddClusteredGeoJsonSource()
        {
            map.Functions.AddSource(
                // Point to GeoJSON data. This example visualizes all M1.0+ earthquakes from
                // 12/22/15 to 1/21/16 as logged by USGS' Earthquake hazards program.
                new GeoJsonSource("earthquakes",
                                  "https://www.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson")
            {
                Options = new GeoJsonOptions
                {
                    Cluster        = (true),
                    ClusterMaxZoom = (14),
                    ClusterRadius  = (50),
                }
            }
                );

            // Use the earthquakes GeoJSON source to create three layers: One layer for each cluster category.
            // Each point range gets a different fill color.
            var layers = new KeyValuePair <int, Color>[] {
                new KeyValuePair <int, Color> (150, Color.FromHex("#f74e4e")),
                new KeyValuePair <int, Color>(20, Color.FromHex("#f74e4e")),
                new KeyValuePair <int, Color>(0, Color.FromHex("#f74e4e"))
            };

            //Creating a marker layer for single data points
            SymbolLayer unclustered = new SymbolLayer("unclustered-points", "earthquakes")
            {
                IconImage = "cross-icon-id",
                IconSize  = Expression.Division(
                    Expression.Get("mag"), Expression.Literal(4.0f)
                    ),
                IconColor = Expression.Interpolate(
                    Expression.Exponential(1), Expression.Get("mag"),
                    Expression.CreateStop(2.0, Expression.Rgb(0, 255, 0)),
                    Expression.CreateStop(4.5, Expression.Rgb(0, 0, 255)),
                    Expression.CreateStop(7.0, Expression.Rgb(255, 0, 0)))
            };

            map.Functions.AddLayer(unclustered);

            for (int i = 0; i < layers.Length; i++)
            {
                var pointCount = Expression.ToNumber(Expression.Get("point_count"));

                //Add clusters' circles
                var circles = new CircleLayer("cluster-" + i, "earthquakes")
                {
                    CircleColor  = layers[i].Value,
                    CircleRadius = 18f,

                    // Add a filter to the cluster layer that hides the circles based on "point_count"
                    Filter = i == 0
                        ? Expression.All(Expression.Has("point_count"), Expression.Gte(pointCount, Expression.Literal(layers[i].Key)))
                        : Expression.All(Expression.Has("point_count"),
                                         Expression.Gte(pointCount, Expression.Literal(layers[i].Key)),
                                         Expression.Lt(pointCount, Expression.Literal(layers[i - 1].Key)))
                };
                map.Functions.AddLayer(circles);
            }

            //Add the count labels
            SymbolLayer count = new SymbolLayer("count", "earthquakes")
            {
                TextField           = Expression.ToString(Expression.Get("point_count")),
                TextSize            = 12f,
                TextColor           = Color.White,
                TextIgnorePlacement = (true),
                TextAllowOverlap    = (true)
            };

            map.Functions.AddLayer(count);
        }
コード例 #24
0
        StyleLayer CreateStyleLayer(MGLVectorStyleLayer vectorLayer, string layerId = null)
        {
            if (vectorLayer is MGLSymbolStyleLayer sl)
            {
                var newLayer = new SymbolLayer(layerId ?? vectorLayer.Identifier, vectorLayer.SourceIdentifier.TrimCustomId());
                if (sl.IconImageName is NSExpression csFunc)
                {
                    var imgName = GetValueFromExpression <NSString>(sl.IconImageName);
                    if (imgName != null)
                    {
                        newLayer.IconImageName = imgName.ToString();
                    }
                }
                else
                {
                    var imgName = GetValueFromExpression <NSString>(sl.IconImageName);
                    if (imgName != null)
                    {
                        newLayer.IconImageName = imgName.ToString();
                    }
                }
                return(newLayer);
            }

            if (vectorLayer is MGLLineStyleLayer ll)
            {
                var newLayer = new LineLayer(layerId ?? vectorLayer.Identifier, vectorLayer.SourceIdentifier.TrimCustomId())
                {
                    LineColor = (GetValueFromExpression <UIColor>(ll.LineColor) as UIColor).ToColor()
                };

                if (ll.LineDashPattern != null)
                {
                    if (GetValueFromExpression <NSArray>(ll.LineDashPattern) is NSArray arr && arr.Count != 0)
                    {
                        var dash = new List <double>();
                        for (nuint i = 0; i < arr.Count; i++)
                        {
                            var obj = arr.GetItem <NSObject>(i);
                            switch (obj)
                            {
                            case NSExpression expression:
                                if (expression.ExpressionType == NSExpressionType.ConstantValue)
                                {
                                    var number = GetValueFromExpression <NSNumber>(expression);
                                    dash.Add(number.DoubleValue);
                                }
                                break;

                            case NSNumber number:
                                dash.Add(number.DoubleValue);
                                break;

                            default:
                                break;
                            }
                        }
                        newLayer.Dashes = dash.ToArray();
                    }
                    else
                    {
                        //TODO
                    }
                }
                return(newLayer);
            }
コード例 #25
0
        private void AddClusteredGeoJsonSource()
        {
            map.Functions.AddSource(
                // Point to GeoJSON data. This example visualizes all M1.0+ earthquakes from
                // 12/22/15 to 1/21/16 as logged by USGS' Earthquake hazards program.
                new GeoJsonSource("earthquakes",
                                  "https://www.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson")
            {
                Options = new GeoJsonOptions
                {
                    Cluster        = (true),
                    ClusterMaxZoom = (14),
                    ClusterRadius  = (50)
                }
            }
                );

            //Creating a SymbolLayer icon layer for single data/icon points
            map.Functions.AddLayer(new SymbolLayer("unclustered-points", "earthquakes")
            {
                IconImage = ("single-quake-icon-id"),
                IconSize  = (
                    Expression.Division(
                        Expression.Get("mag"), Expression.Literal(4.0f)
                        )
                    )
            });

            // Use the earthquakes GeoJSON source to create three point ranges.
            int[] layers = new int[] { 150, 20, 0 };

            for (int i = 0; i < layers.Length; i++)
            {
                //Add clusters' SymbolLayers images
                SymbolLayer symbolLayer = new SymbolLayer("cluster-" + i, "earthquakes");

                symbolLayer.IconImage = ("quake-triangle-icon-id");
                Expression pointCount = Expression.ToNumber(Expression.Get("point_count"));

                // Add a filter to the cluster layer that hides the icons based on "point_count"
                symbolLayer.Filter = (
                    i == 0
                    ? Expression.All(Expression.Has("point_count"),
                                     Expression.Gte(pointCount, Expression.Literal(layers[i]))
                                     ) : Expression.All(Expression.Has("point_count"),
                                                        Expression.Gte(pointCount, Expression.Literal(layers[i])),
                                                        Expression.Lt(pointCount, Expression.Literal(layers[i - 1]))
                                                        )
                    );
                map.Functions.AddLayer(symbolLayer);
            }

            //Add a SymbolLayer for the cluster data number point count
            map.Functions.AddLayer(new SymbolLayer("count", "earthquakes")
            {
                TextField           = (Expression.ToString(Expression.Get("point_count"))),
                TextSize            = (12f),
                TextColor           = (Color.Black),
                TextIgnorePlacement = (true),
                // The .5f offset moves the data numbers down a little bit so that they're
                // in the middle of the triangle cluster image
                TextOffset       = (new float[] { 0f, .5f }),
                TextAllowOverlap = (true)
            });
        }
コード例 #26
0
                    public BaseObject Create()
                    {
                        SymbolLayer emptyInstance = new SymbolLayer(CreatedWhenConstruct.CWC_NotToCreate);

                        return(emptyInstance);
                    }