예제 #1
0
        private async void Initialize()
        {
            try
            {
                // Starting viewpoint for the map view.
                Viewpoint _startingViewpoint = new Viewpoint(new Envelope(-9812691.11079696, 5128687.20710657, -9812377.9447607, 5128865.36767282, SpatialReferences.WebMercator));

                // Create the map.
                MyMapView.Map = new Map(Basemap.CreateStreetsNightVector())
                {
                    InitialViewpoint = _startingViewpoint
                };

                // NOTE: This layer supports any ArcGIS Feature Table that define subtypes.
                SubtypeFeatureLayer subtypeFeatureLayer = new SubtypeFeatureLayer(new ServiceFeatureTable(new Uri("https://sampleserver7.arcgisonline.com/arcgis/rest/services/UtilityNetwork/NapervilleElectric/FeatureServer/100")));
                MyMapView.Map.OperationalLayers.Add(subtypeFeatureLayer);

                // Select sublayer to control.
                await subtypeFeatureLayer.LoadAsync();

                // Select the sublayer of street lights by name.
                _sublayer = subtypeFeatureLayer.GetSublayerBySubtypeName("Street Light");

                // Set the label definitions using the JSON.
                _sublayer.LabelDefinitions.Add(LabelDefinition.FromJson(_labelJSON));

                // Enable labels for the sub layer.
                _sublayer.LabelsEnabled = true;

                // Set the data context for data-binding in XAML.
                SublayerInfo.DataContext = _sublayer;

                // Get the default renderer for the sublayer.
                _defaultRenderer = _sublayer.Renderer.Clone();

                // Create a custom renderer for the sublayer.
                _customRenderer = new SimpleRenderer()
                {
                    Symbol = new SimpleMarkerSymbol()
                    {
                        Color = Color.Salmon,
                        Style = SimpleMarkerSymbolStyle.Diamond,
                        Size  = 20,
                    }
                };

                // Set a default minimum scale.
                _sublayer.MinScale = 3000;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private async void Initialize()
        {
            try
            {
                // Starting viewpoint for the map view.
                Viewpoint _startingViewpoint = new Viewpoint(new Envelope(-9812691.11079696, 5128687.20710657, -9812377.9447607, 5128865.36767282, SpatialReferences.WebMercator));

                // Create the map.
                MyMapView.Map = new Map(Basemap.CreateStreetsNightVector())
                {
                    InitialViewpoint = _startingViewpoint
                };

                // NOTE: This layer supports any ArcGIS Feature Table that define subtypes.
                SubtypeFeatureLayer subtypeFeatureLayer = new SubtypeFeatureLayer(new ServiceFeatureTable(new Uri("https://sampleserver7.arcgisonline.com/arcgis/rest/services/UtilityNetwork/NapervilleElectric/FeatureServer/100")));
                MyMapView.Map.OperationalLayers.Add(subtypeFeatureLayer);

                // Select sublayer to control.
                await subtypeFeatureLayer.LoadAsync();

                // Select the sublayer of street lights by name.
                _sublayer = subtypeFeatureLayer.GetSublayerBySubtypeName("Street Light");

                // Set the label definitions using the JSON.
                _sublayer.LabelDefinitions.Add(LabelDefinition.FromJson(_labelJSON));

                // Enable labels for the sub layer.
                _sublayer.LabelsEnabled = true;

                // Get the default renderer for the sublayer.
                _defaultRenderer = _sublayer.Renderer.Clone();

                // Create a custom renderer for the sublayer.
                _customRenderer = new SimpleRenderer()
                {
                    Symbol = new SimpleMarkerSymbol()
                    {
                        Color = System.Drawing.Color.Salmon,
                        Style = SimpleMarkerSymbolStyle.Diamond,
                        Size  = 20,
                    }
                };

                // Update the UI for displaying the current map scale.
                MyMapView.PropertyChanged += MapViewPropertyChanged;
                MapScaleLabel.Text         = $"Current map scale: 1:{(int)MyMapView.MapScale}";
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert(ex.GetType().Name, ex.Message, "OK");
            }
        }
예제 #3
0
        public static LabelDefinition BuildLabelWithId(String idKey, String labelKey, String latKey, String longKey, bool displayLocation, int textSize, Color textColor, Color haloColor)
        {
            var textColorValues = new int[] { textColor.R, textColor.G, textColor.B, textColor.A };
            var haloColorValues = new int[] { haloColor.R, haloColor.G, haloColor.B, haloColor.A };

            var labelJson = @"{
      ""labelExpression"": ""[" + idKey + @"]"",
      ""labelExpressionInfo"": {
            ""expression"": ""return $feature[\""" + labelKey + @"\""]" + (displayLocation ? @" + \"" Lat: \"" + $feature[\""" + latKey + @"\""] + \"" Long: \"" + $feature[\""" + longKey + @"\""]" : String.Empty) + @";""
      },
      ""useCodedValues"": false,
      ""maxScale"": 0,
      ""minScale"": 0,
      ""deconflictionStrategy"": ""none"",
      ""labelPlacement"": ""esriServerPointLabelPlacementCenterRight"",
      ""symbol"": {
                    ""color"": [" + textColorValues[0] + @",
                                " + textColorValues[1] + @",
                                " + textColorValues[2] + @",
                                " + textColorValues[3] + @"],
                    ""type"": ""esriTS"",
                    ""haloSize"": 2,
                    ""haloColor"": [
                                " + haloColorValues[0] + @",
                                " + haloColorValues[1] + @",
                                " + haloColorValues[2] + @",
                                " + haloColorValues[3] + @"],
                    ""horizontalAlignment"": ""left"",
                    ""rightToLeft"": false,
                    ""angle"": 0,
                    ""xoffset"": 0,
                    ""yoffset"": 0,
                    ""text"": """",
                    ""rotated"": false,
                    ""kerning"": true,
                    ""font"": {
                        ""size"": " + textSize + @",
                        ""style"": ""normal"",
                        ""decoration"": ""none"",
                        ""weight"": ""bold"", 
                        ""family"": ""Arial""
                    }
          }
}";

            return(LabelDefinition.FromJson(labelJson));
        }
예제 #4
0
        private async void Initialize()
        {
            // Create a map with a light gray canvas basemap.
            Map sampleMap = new Map(Basemap.CreateLightGrayCanvas());

            // Assign the map to the MapView.
            _myMapView.Map = sampleMap;

            // Define the URL string for the feature layer.
            const string layerUrl = "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/USA_115th_Congressional_Districts/FeatureServer/0";

            // Create a service feature table from the URL.
            ServiceFeatureTable featureTable = new ServiceFeatureTable(new Uri(layerUrl));

            // Create a feature layer from the service feature table.
            FeatureLayer districtFeatureLabel = new FeatureLayer(featureTable);

            // Add the feature layer to the operations layers collection of the map.
            sampleMap.OperationalLayers.Add(districtFeatureLabel);

            try
            {
                // Load the feature layer - this way we can obtain it's extent.
                await districtFeatureLabel.LoadAsync();

                // Zoom the map view to the extent of the feature layer.
                await _myMapView.SetViewpointCenterAsync(new MapPoint(-10846309.950860, 4683272.219411, SpatialReferences.WebMercator), 20000000);

                // Create a label definition from the JSON string.
                LabelDefinition redLabelDefinition  = LabelDefinition.FromJson(RedLabelJson);
                LabelDefinition blueLabelDefinition = LabelDefinition.FromJson(BlueLabelJson);

                // Add the label definition to the feature layer's label definition collection.
                districtFeatureLabel.LabelDefinitions.Add(redLabelDefinition);
                districtFeatureLabel.LabelDefinitions.Add(blueLabelDefinition);

                // Enable the visibility of labels to be seen.
                districtFeatureLabel.LabelsEnabled = true;
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
예제 #5
0
        private static LabelDefinition CreateLabelDefinition(string expression, string placement, Color textColor)
        {
            var jsonBuilder = new StringBuilder();

            jsonBuilder.Append(@"{");
            jsonBuilder.Append(CreateJsonPropertyAsString(@"labelExpression", expression));
            jsonBuilder.Append(@",");
            jsonBuilder.Append(CreateJsonPropertyAsString(@"labelPlacement", placement));
            var labelTextSymbol = new TextSymbol();

            labelTextSymbol.Color      = textColor;
            labelTextSymbol.Size       = 12;
            labelTextSymbol.FontFamily = @"Arial";
            labelTextSymbol.FontStyle  = FontStyle.Normal;
            labelTextSymbol.FontWeight = FontWeight.Bold;
            var symbolAsJson = labelTextSymbol.ToJson();

            jsonBuilder.Append(@",");
            jsonBuilder.Append("\"symbol\":");
            jsonBuilder.Append(symbolAsJson);
            jsonBuilder.Append(@"}");
            return(LabelDefinition.FromJson(jsonBuilder.ToString()));
        }
예제 #6
0
        private async void Initialize()
        {
            // Create a map with a light gray canvas basemap.
            Map sampleMap = new Map(Basemap.CreateLightGrayCanvas());

            // Assign the map to the MapView.
            MyMapView.Map = sampleMap;

            // Define the URL string for the feature layer.
            string layerUrl = "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/USA_115th_Congressional_Districts/FeatureServer/0";

            // Create a service feature table from the URL.
            ServiceFeatureTable featureTable = new ServiceFeatureTable(new System.Uri(layerUrl));

            // Create a feature layer from the service feature table.
            FeatureLayer districtFeatureLabel = new FeatureLayer(featureTable);

            // Add the feature layer to the operations layers collection of the map.
            sampleMap.OperationalLayers.Add(districtFeatureLabel);

            // Load the feature layer - this way we can obtain it's extent.
            await districtFeatureLabel.LoadAsync();

            // Zoom the map view to the extent of the feature layer.
            await MyMapView.SetViewpointCenterAsync(new MapPoint(-10846309.950860, 4683272.219411, SpatialReferences.WebMercator), 20000000);

            // Help regarding the Json syntax for defining the LabelDefinition.FromJson syntax can be found here:
            // https://developers.arcgis.com/web-map-specification/objects/labelingInfo/
            // This particular JSON string will have the following characteristics:
            string redLabelJson =
                @"{
                    ""labelExpressionInfo"":{""expression"":""$feature.NAME + ' (' + left($feature.PARTY,1) + ')\\nDistrict' + $feature.CDFIPS""},
                    ""labelPlacement"":""esriServerPolygonPlacementAlwaysHorizontal"",
                    ""where"":""PARTY = 'Republican'"",
                    ""symbol"":
                        { 
                            ""angle"":0,
                            ""backgroundColor"":[0,0,0,0],
                            ""borderLineColor"":[0,0,0,0],
                            ""borderLineSize"":0,
                            ""color"":[255,0,0,255],
                            ""font"":
                                {
                                    ""decoration"":""none"",
                                    ""size"":10,
                                    ""style"":""normal"",
                                    ""weight"":""normal""
                                },
                            ""haloColor"":[255,255,255,255],
                            ""haloSize"":2,
                            ""horizontalAlignment"":""center"",
                            ""kerning"":false,
                            ""type"":""esriTS"",
                            ""verticalAlignment"":""middle"",
                            ""xoffset"":0,
                            ""yoffset"":0
                        }
               }";

            string blueLabelJson =
                @"{
                    ""labelExpressionInfo"":{""expression"":""$feature.NAME + ' (' + left($feature.PARTY,1) + ')\\nDistrict' + $feature.CDFIPS""},
                    ""labelPlacement"":""esriServerPolygonPlacementAlwaysHorizontal"",
                    ""where"":""PARTY = 'Democrat'"",
                    ""symbol"":
                        { 
                            ""angle"":0,
                            ""backgroundColor"":[0,0,0,0],
                            ""borderLineColor"":[0,0,0,0],
                            ""borderLineSize"":0,
                            ""color"":[0,0,255,255],
                            ""font"":
                                {
                                    ""decoration"":""none"",
                                    ""size"":10,
                                    ""style"":""normal"",
                                    ""weight"":""normal""
                                },
                            ""haloColor"":[255,255,255,255],
                            ""haloSize"":2,
                            ""horizontalAlignment"":""center"",
                            ""kerning"":false,
                            ""type"":""esriTS"",
                            ""verticalAlignment"":""middle"",
                            ""xoffset"":0,
                            ""yoffset"":0
                        }
               }";

            // Create a label definition from the JSON string.
            LabelDefinition redLabelDefinition  = LabelDefinition.FromJson(redLabelJson);
            LabelDefinition blueLabelDefinition = LabelDefinition.FromJson(blueLabelJson);

            // Add the label definition to the feature layer's label definition collection.
            districtFeatureLabel.LabelDefinitions.Add(redLabelDefinition);
            districtFeatureLabel.LabelDefinitions.Add(blueLabelDefinition);

            // Enable the visibility of labels to be seen.
            districtFeatureLabel.LabelsEnabled = true;
        }
예제 #7
0
        private async void Initialize()
        {
            // Create a map with a light gray canvas basemap.
            Map sampleMap = new Map(Basemap.CreateLightGrayCanvas())
            {
                InitialViewpoint = new Viewpoint(new MapPoint(-100.175709, 39.221225, SpatialReferences.Wgs84), 20000000)
            };

            // Assign the map to the MapView.
            _myMapView.Map = sampleMap;

            // Define the URL string for the US highways feature layer.
            string highwaysUrlString = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/1";

            // Create a service feature table from the URL to the US highways feature service.
            ServiceFeatureTable highwaysServiceFeatureTable = new ServiceFeatureTable(new Uri(highwaysUrlString));

            // Create a feature layer from the service feature table.
            FeatureLayer highwaysFeatureLayer = new FeatureLayer(highwaysServiceFeatureTable);

            // Add the US highways feature layer to the operations layers collection of the map.
            sampleMap.OperationalLayers.Add(highwaysFeatureLayer);

            // Load the US highways feature layer - this way we can obtain it's extent.
            await highwaysFeatureLayer.LoadAsync();

            // Help regarding the JSON syntax for defining the LabelDefinition.FromJson syntax can be found here:
            // https://developers.arcgis.com/web-map-specification/objects/labelingInfo/
            // This particular JSON string will have the following characteristics:
            // (1) The 'labelExpressionInfo' defines that the label text displayed comes from the field 'rte_num1' in the
            //     feature service and will be prefaced with an "I -". Example: "I - 10", "I - 15", "I - 95", etc.
            // (2) The 'labelPlacement' will be placed above and along the highway polyline segment.
            // (3) The 'where' clause restricts the labels to be displayed that has valid (non-empty) data. Empty data
            //     for this service has a single blank space in the 'rte_num1' field.
            // (4) The 'symbol' for the labeled text will be blue with a yellow halo.
            string theJsonString =
                @"{
                    ""labelExpressionInfo"":{""expression"":""'I - ' + $feature.rte_num1""},
                    ""labelPlacement"":""esriServerLinePlacementAboveAlong"",
                    ""where"":""rte_num1 <> ' '"",
                    ""symbol"":
                        { 
                            ""angle"":0,
                            ""backgroundColor"":[0,0,0,0],
                            ""borderLineColor"":[0,0,0,0],
                            ""borderLineSize"":0,
                            ""color"":[0,0,255,255],
                            ""font"":
                                {
                                    ""decoration"":""none"",
                                    ""size"":15,
                                    ""style"":""normal"",
                                    ""weight"":""normal""
                                },
                            ""haloColor"":[255,255,0,255],
                            ""haloSize"":1.5,
                            ""horizontalAlignment"":""center"",
                            ""kerning"":false,
                            ""type"":""esriTS"",
                            ""verticalAlignment"":""middle"",
                            ""xoffset"":0,
                            ""yoffset"":0
                        }
               }";

            // Create a label definition from the JSON string.
            LabelDefinition highwaysLabelDefinition = LabelDefinition.FromJson(theJsonString);

            // Add the label definition to the feature layer's label definition collection.
            highwaysFeatureLayer.LabelDefinitions.Add(highwaysLabelDefinition);

            // Enable the visibility of labels to be seen.
            highwaysFeatureLayer.LabelsEnabled = true;
        }
예제 #8
0
        // 测试用方法
        private async void myTestBtn2_Click(object sender, RoutedEventArgs e)
        {
            //myLegend.GeoView = null;


            // Help regarding the Json syntax for defining the LabelDefinition.FromJson syntax can be found here:
            // https://developers.arcgis.com/web-map-specification/objects/labelingInfo/
            // This particular JSON string will have the following characteristics:
            string redLabelJson =
                @"{
                    ""labelExpressionInfo"":{""expression"":""$feature.NAME + ' (' + left($feature.PARTY,1) + ')\\nDistrict' + $feature.CDFIPS""},
                    ""labelPlacement"":""esriServerPolygonPlacementAlwaysHorizontal"",
                    ""where"":""PARTY = 'Republican'"",
                    ""symbol"":
                        { 
                            ""angle"":0,
                            ""backgroundColor"":[0,0,0,0],
                            ""borderLineColor"":[0,0,0,0],
                            ""borderLineSize"":0,
                            ""color"":[255,0,0,255],
                            ""font"":
                                {
                                    ""decoration"":""none"",
                                    ""size"":10,
                                    ""style"":""normal"",
                                    ""weight"":""normal""
                                },
                            ""haloColor"":[255,255,255,255],
                            ""haloSize"":2,
                            ""horizontalAlignment"":""center"",
                            ""kerning"":false,
                            ""type"":""esriTS"",
                            ""verticalAlignment"":""middle"",
                            ""xoffset"":0,
                            ""yoffset"":0
                        }
               }";

            string blueLabelJson =
                @"{
                    ""labelExpressionInfo"":{""expression"":""$feature.NAME + ' (' + left($feature.PARTY,1) + ')\\nDistrict' + $feature.CDFIPS""},
                    ""labelPlacement"":""esriServerPolygonPlacementAlwaysHorizontal"",
                    ""where"":""PARTY = 'Democrat'"",
                    ""symbol"":
                        { 
                            ""angle"":0,
                            ""backgroundColor"":[0,0,0,0],
                            ""borderLineColor"":[0,0,0,0],
                            ""borderLineSize"":0,
                            ""color"":[0,0,255,255],
                            ""font"":
                                {
                                    ""decoration"":""none"",
                                    ""size"":10,
                                    ""style"":""normal"",
                                    ""weight"":""normal""
                                },
                            ""haloColor"":[255,255,255,255],
                            ""haloSize"":2,
                            ""horizontalAlignment"":""center"",
                            ""kerning"":false,
                            ""type"":""esriTS"",
                            ""verticalAlignment"":""middle"",
                            ""xoffset"":0,
                            ""yoffset"":0
                        }
               }";

            string s3 = @"{
  ""labelExpressionInfo"": 
  {
                ""expression"": ""return $feature.FID;""
  },
  ""labelPlacement"": ""esriServerLinePlacementBelowAlong"",
  ""symbol"": 
  {
                ""color"": [255,0,255,123],
    ""font"": { ""size"": 16 },
    ""type"": ""esriTS""
  }
}";

            // Create a label definition from the JSON string.
            LabelDefinition redLabelDefinition  = LabelDefinition.FromJson(redLabelJson);
            LabelDefinition blueLabelDefinition = LabelDefinition.FromJson(blueLabelJson);
            LabelDefinition l3 = LabelDefinition.FromJson(s3);

            // Add the label definition to the feature layer's label definition collection.
            FeatureLayer a = (FeatureLayer)myMapView.Map.OperationalLayers[0];

            a.LabelDefinitions.Add(redLabelDefinition);
            a.LabelDefinitions.Add(blueLabelDefinition);
            a.LabelDefinitions.Add(l3);

            // Enable the visibility of labels to be seen.
            a.LabelsEnabled = true;
        }
예제 #9
0
        private void addBtn_Click(object sender, RoutedEventArgs e)
        {
            string redLabelJson =
                @"{
                   ""labelExpressionInfo"":{""expression"":""return $feature." + chooseField + @";""},
                   ""labelPlacement"":""esriServerPolygonPlacementAlwaysHorizontal"",
                   ""symbol"":
                       { 
                           ""angle"":0,
                           ""backgroundColor"":[0,0,0,0],
                           ""borderLineColor"":[0,0,0,0],
                           ""borderLineSize"":0,
                           ""color"":[255,0,0,255],
                           ""font"":
                               {
                                   ""decoration"":""none"",
                                   ""size"":10,
                                   ""style"":""normal"",
                                   ""weight"":""normal""
                               },
                           ""haloColor"":[255,255,255,255],
                           ""haloSize"":2,
                           ""horizontalAlignment"":""center"",
                           ""kerning"":false,
                           ""type"":""esriTS"",
                           ""verticalAlignment"":""middle"",
                           ""xoffset"":0,
                           ""yoffset"":0
                       }
              }";

            string blueLabelJson =
                @"{
                    ""labelExpressionInfo"":{""expression"":""return $feature." + chooseField + @";""},
                    ""labelPlacement"":""esriServerPolygonPlacementAlwaysHorizontal"",
                    ""symbol"":
                        { 
                            ""angle"":0,
                            ""backgroundColor"":[0,0,0,0],
                            ""borderLineColor"":[0,0,0,0],
                            ""borderLineSize"":0,
                            ""color"":[0,0,255,255],
                            ""font"":
                                {
                                    ""decoration"":""none"",
                                    ""size"":10,
                                    ""style"":""normal"",
                                    ""weight"":""normal""
                                },
                            ""haloColor"":[255,255,255,255],
                            ""haloSize"":2,
                            ""horizontalAlignment"":""center"",
                            ""kerning"":false,
                            ""type"":""esriTS"",
                            ""verticalAlignment"":""middle"",
                            ""xoffset"":0,
                            ""yoffset"":0
                        }
               }";

            LabelDefinition redLabelDefinition  = LabelDefinition.FromJson(redLabelJson);
            LabelDefinition blueLabelDefinition = LabelDefinition.FromJson(blueLabelJson);

            if (labelTypeComboBox.SelectedIndex == 0)
            {
                LabelDefinition l3 = LabelDefinition.FromJson(redLabelJson);
                l3 = LabelDefinition.FromJson(redLabelJson);
                a.LabelDefinitions.Add(redLabelDefinition);
                a.LabelDefinitions.Add(l3);
            }
            else if (labelTypeComboBox.SelectedIndex == 1)
            {
                LabelDefinition l3 = LabelDefinition.FromJson(redLabelJson);
                l3 = LabelDefinition.FromJson(blueLabelJson);
                a.LabelDefinitions.Add(blueLabelDefinition);
                a.LabelDefinitions.Add(l3);
            }

            a.LabelsEnabled = true;
        }
        public async void Initialize()
        {
            string licenseKey = "runtimelite,1000,rud3766972362,none,MJJC7XLS1HSB003AD015";

            Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.SetLicense(licenseKey);

            //Map myMap = new Map(Basemap.CreateTerrainWithLabels());
            Map myMap = new Map(BasemapType.LightGrayCanvasVector, 35.728990, -78.856027, 18);

            // TEST GDB SERVICE VS MAP SERVICE
            // http://apexgis:6080/arcgis/rest/services/CemeteryHost/CEMTESTSERV/GeoDataServer/versions/dbo.DEFAULT
            // WFS serv http://apexgis:6080/arcgis/services/C+emeteryHost/CEMTESTSERV/GeoDataServer/WFSServer


            // LEGEND ILayerContent

            //var CemLot = new Uri("http://apexgis:6080/arcgis/rest/services/CemeteryHost/CEMTESTSERV/FeatureServer/0");
            var          CemLot   = new Uri("http://apexgis:6080/arcgis/rest/services/CemeteryHost/CEMPRODSERV/FeatureServer/0");
            FeatureLayer LotLayer = new FeatureLayer(CemLot);
            await LotLayer.LoadAsync();

            SimpleLineSymbol LotLineSymb = new SimpleLineSymbol(
                SimpleLineSymbolStyle.Solid, System.Drawing.Color.Black, 1);

            SimpleFillSymbol lotSymbol = new SimpleFillSymbol()
            {
                Color   = System.Drawing.Color.Transparent,
                Outline = LotLineSymb,
            };

            SimpleRenderer LotRenderer = new SimpleRenderer(lotSymbol);

            // Lot label info
            StringBuilder LotStringLabelBuild = new StringBuilder();

            LotStringLabelBuild.AppendLine("{");

            LotStringLabelBuild.AppendLine("\"labelExpressionInfo\": {");
            LotStringLabelBuild.AppendLine("\"expression\": \"return $feature.LOT_ID;\"},");
            LotStringLabelBuild.AppendLine("\"maxScale\": 50,");
            LotStringLabelBuild.AppendLine("\"minScale\": 1000,");
            //     Align labels above the center of each point
            LotStringLabelBuild.AppendLine("\"labelPlacement\": \"esriServerPolygonPlacementAlwaysHorizontal\",");
            //     Use a white bold text symbol
            LotStringLabelBuild.AppendLine("\"symbol\": {");
            // Color ARGB  [R  ALPHA  B  G]
            LotStringLabelBuild.AppendLine("\"color\": [13,38,68,255],");
            LotStringLabelBuild.AppendLine("\"font\": {\"size\": 9, \"weight\": \"bold\"},");
            LotStringLabelBuild.AppendLine("\"type\": \"esriTS\"}");

            LotStringLabelBuild.AppendLine("}");

            var LotLabelsJson = LotStringLabelBuild.ToString();

            LabelDefinition LotLabelsDef = LabelDefinition.FromJson(LotLabelsJson);

            LotLayer.LabelDefinitions.Clear();

            LotLayer.LabelDefinitions.Add(LotLabelsDef);
            LotLayer.LabelsEnabled = true;

            // CemPlot Properties

            //var CemPlot = new Uri("http://apexgis:6080/arcgis/rest/services/CemeteryHost/CEMTESTSERV/FeatureServer/1");
            var CemPlot = new Uri("http://apexgis:6080/arcgis/rest/services/CemeteryHost/CEMPRODSERV/FeatureServer/1");

            FeatureLayer PlotLayer = new FeatureLayer(CemPlot);

            await PlotLayer.LoadAsync();

            var CemPlot2 = new Uri("http://apexgis:6080/arcgis/rest/services/CemeteryHost/CEMPRODSERV/FeatureServer/1");

            FeatureLayer PlotLayer2 = new FeatureLayer(CemPlot);


            // Plot Label Properties

            StringBuilder PlotStringLabelBuild = new StringBuilder();

            PlotStringLabelBuild.AppendLine("{");

            PlotStringLabelBuild.AppendLine("\"labelExpressionInfo\": {");
            PlotStringLabelBuild.AppendLine("\"expression\": \"return $feature.plot;\"},");
            PlotStringLabelBuild.AppendLine("\"maxScale\": 10,");
            PlotStringLabelBuild.AppendLine("\"minScale\": 250,");
            //     Align labels above the center of each point
            PlotStringLabelBuild.AppendLine("\"labelPlacement\": \"esriServerPolygonPlacementAlwaysHorizontal\",");
            //     Use a white bold text symbol
            PlotStringLabelBuild.AppendLine("\"symbol\": {");
            // Color ARGB  [R  ALPHA  B  G]
            PlotStringLabelBuild.AppendLine("\"color\": [13,38,68,255],");
            PlotStringLabelBuild.AppendLine("\"font\": {\"size\": 8, \"weight\": \"italic\"},");
            PlotStringLabelBuild.AppendLine("\"type\": \"esriTS\"}");

            PlotStringLabelBuild.AppendLine("}");

            var PlotLabelsJson = PlotStringLabelBuild.ToString();

            LabelDefinition PlotLabelsDef = LabelDefinition.FromJson(PlotLabelsJson);

            PlotLayer.LabelDefinitions.Clear();

            PlotLayer.LabelDefinitions.Add(PlotLabelsDef);
            PlotLayer.LabelsEnabled = true;

            // Plot Symbology

            var plotRenderer2 = new UniqueValueRenderer();

            plotRenderer2.FieldNames.Add("name_LAST");

            var plotOutline = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.White, 1);

            var town_plot = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.ColorTranslator.FromHtml("#DB87F2"), plotOutline);

            plotRenderer2.UniqueValues.Add(new UniqueValue("Town Own", "Town Own", town_plot, "APEX"));
            plotRenderer2.UniqueValues.Add(new UniqueValue("Town Own", "Town Own", town_plot, "TOWN OF APEX"));


            var defaultFillSymbol2 = new SimpleFillSymbol(SimpleFillSymbolStyle.Null, System.Drawing.Color.Transparent, plotOutline);

            plotRenderer2.DefaultSymbol = defaultFillSymbol2;

            //plotRenderer.SceneProperties
            var plotRenderer = new UniqueValueRenderer();

            plotRenderer.FieldNames.Add("Plot_status");


            var validPlot   = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.ColorTranslator.FromHtml("#8DC055"), plotOutline);
            var unvalidPlot = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.ColorTranslator.FromHtml("#F9F07F"), plotOutline);
            var notsaleable = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.ColorTranslator.FromHtml("#F5503B"), plotOutline);

            plotRenderer.UniqueValues.Add(new UniqueValue("Valid Plot", "Valid Plot", validPlot, "Deeded"));
            plotRenderer.UniqueValues.Add(new UniqueValue("Unvalid", "Unvalid Plot", unvalidPlot, "Unknown"));
            plotRenderer.UniqueValues.Add(new UniqueValue("No Sale", "No Sell", notsaleable, "Not Saleable"));

            var defaultFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Null, System.Drawing.Color.Transparent, plotOutline);

            plotRenderer.DefaultSymbol = defaultFillSymbol;
            plotRenderer.DefaultLabel  = "Other";

            // CemBoundary Graphics

            //var CemBound = new Uri("http://apexgis:6080/arcgis/rest/services/CemeteryHost/CEMTESTSERV/FeatureServer/2");

            var          CemBound   = new Uri("http://apexgis:6080/arcgis/rest/services/CemeteryHost/CEMPRODSERV/FeatureServer/2");
            FeatureLayer BoundLayer = new FeatureLayer(CemBound);

            SimpleLineSymbol BoundLineSymb = new SimpleLineSymbol(
                SimpleLineSymbolStyle.Solid, System.Drawing.Color.IndianRed, 3);

            SimpleFillSymbol symbol = new SimpleFillSymbol()
            {
                Outline = BoundLineSymb,
            };



            SimpleRenderer renderer = new SimpleRenderer(symbol);

            // Main GIS Operation Calls

            BoundLayer.Renderer = renderer;
            PlotLayer.Renderer  = plotRenderer;
            LotLayer.Renderer   = LotRenderer;
            PlotLayer2.Renderer = plotRenderer2;


            myMap.OperationalLayers.Add(BoundLayer);
            myMap.OperationalLayers.Add(PlotLayer);
            myMap.OperationalLayers.Add(PlotLayer2);
            myMap.OperationalLayers.Add(LotLayer);

            // Assign the map to the MapView
            myMap.MinScale = 2250;
            myMap.MaxScale = 30;



            MyMapView.Map            = myMap;
            MyMapView.GeoViewTapped += MyMapView_GeoViewTapped;
        }
예제 #11
0
        private void get_feature_layer()
        {
            /***********************************************************************
             *   This function loads a feature layer from arcGIS online
             ************************************************************************/
            // Create new Map with basemap
            myMap = new Map(Basemap.CreateTopographic());


            // Create and set initial map area
            Envelope initialLocation = new Envelope(
                -160.6739, 13.3844, -179.5449, 80.2319,
                SpatialReferences.Wgs84);

            myMap.InitialViewpoint = new Viewpoint(initialLocation);


            /***********************************************************************
             *   Turtle Feature Layer
             ************************************************************************/
            // Create uri to the used feature service
            var serviceUri = new Uri(
                "https://services6.arcgis.com/kInEIOmrLNzXMSuZ/arcgis/rest/services/Turtles/FeatureServer/0");

            // Create feature table using a URL.
            _featureTable = new ServiceFeatureTable(serviceUri);

            MyMapView.Map = myMap;

            // Create feature layer using this feature table. Make it slightly transparent.
            _featureLayer = new FeatureLayer(_featureTable);

            string theJSON_String =
                @"{
                    ""labelExpressionInfo"":{""expression"":""$feature.Species""},
                    ""labelPlacement"":""esriServerLinePlacementAboveAlong"",
                    ""where"":""Species <> ' '"",
                    ""symbol"":
                        { 
                            ""angle"":0,
                            ""backgroundColor"":[0,0,0,0],
                            ""borderLineColor"":[0,0,0,0],
                            ""borderLineSize"":0,
                            ""color"":[51, 51, 51, 255],
                            ""font"":
                                {
                                    ""decoration"":""none"",
                                    ""size"":10,
                                    ""style"":""normal"",
                                    ""weight"":""normal""
                                },
                            ""haloColor"":[0,0,0,0],
                            ""haloSize"":1.5,
                            ""horizontalAlignment"":""center"",
                            ""kerning"":false,
                            ""type"":""esriTS"",
                            ""verticalAlignment"":""middle"",
                            ""xoffset"":0,
                            ""yoffset"":0
                        }
               }";

            // Create a label definition from the JSON string.
            LabelDefinition turtleSpeciesLabelDefinition = LabelDefinition.FromJson(theJSON_String);


            /***********************************************************************
             *   Air Temp Feature Layer
             ************************************************************************/
            var airServiceUri = new Uri(
                "https://services6.arcgis.com/kInEIOmrLNzXMSuZ/arcgis/rest/services/Air_Temp_/FeatureServer/0");

            // Create feature table using a URL.
            _airFeatureTable = new ServiceFeatureTable(airServiceUri);

            // Create feature layer using this feature table. Make it slightly transparent.
            _airFeatureLayer = new FeatureLayer(_airFeatureTable)
            {
                Opacity = 0.6
            };

            /***********************************************************************
             *   Wind Feature Layer
             ************************************************************************/
            var windServiceUri = new Uri(
                "https://services6.arcgis.com/kInEIOmrLNzXMSuZ/arcgis/rest/services/Wind/FeatureServer/0");

            // Create feature table using a URL.
            _windFeatureTable = new ServiceFeatureTable(windServiceUri);

            // Create feature layer using this feature table. Make it slightly transparent.
            _windFeatureLayer = new FeatureLayer(_windFeatureTable)
            {
                Opacity = 0.6
            };

            /***********************************************************************
             *   Sea Surface Temperature Feature Layer
             ************************************************************************/
            var seaTempServiceUri = new Uri(
                "https://services6.arcgis.com/kInEIOmrLNzXMSuZ/arcgis/rest/services/Sea_Temp/FeatureServer/0");

            // Create feature table using a URL.
            _seaTempFeatureTable = new ServiceFeatureTable(seaTempServiceUri);

            // Create feature layer using this feature table. Make it slightly transparent.
            _seaTempFeatureLayer = new FeatureLayer(_seaTempFeatureTable)
            {
                Opacity = 0.6
            };

            // add feature layers to map

            /* myMap.OperationalLayers.Add(_featureLayer);
             * myMap.OperationalLayers.Add(_airFeatureLayer);
             * myMap.OperationalLayers.Add(_windFeatureLayer);
             * myMap.OperationalLayers.Add(_seaTempFeatureLayer);*/


            // Add the label definition to the feature layer's label definition collection.
            _featureLayer.LabelDefinitions.Add(turtleSpeciesLabelDefinition);

            // Enable the visibility of labels to be seen.
            _featureLayer.LabelsEnabled = true;

            MyMapView.TimeExtent = new TimeExtent(start, end);

            // add the map to the map view
            MyMapView.Map = myMap;
        }