Esempio n. 1
0
        // Summary:
        //     Add a layer in a shape file
        //     The name of the layer and display options are specified in the LocalELayer
        //
        public async Task <IGraphicsLayer> addShpLayer(LayerDef layerDef,
                                                       string shpFile, int start = 0, int maxFeatures = 0)
        {
            if (layerDef == null || shpFile == null)
            {
                return(null);
            }
            string filePath = _prj.projDef.LocalFilePath + "\\" + shpFile;

            if (File.Exists(filePath))
            {
                ShapefileTable table = await ShapefileTable.OpenAsync(filePath);

                if (table == null)
                {
                    return(null);
                }

                IS3GraphicsLayer gLayer = await featureTable2GraphicsLayer(
                    table, start, maxFeatures, true);

                if (gLayer == null)
                {
                    return(null);
                }

                gLayer.ID = layerDef.Name;
                setGraphicLayerDisplayOptions(layerDef, gLayer);

                _map.Layers.Add(gLayer);
                return(gLayer);
            }
            return(null);
        }
        private async Task LoadShapefile(string path)
        {
            try
            {
                _featureOverlay.Visibility = Visibility.Collapsed;

                // open shapefile table
                var shapefile = await ShapefileTable.OpenAsync(path);

                // clear existing map and spatial reference
                if (MyMapView.Map.Layers.Any())
                {
                    MyMapView.Map.Layers.Clear();
                    MyMapView.Map = new Map();
                }

                // create feature layer based on the shapefile
                var flayer = new FeatureLayer(shapefile)
                {
                    ID          = shapefile.Name,
                    DisplayName = Path.GetFileName(path),
                };

                // Add the feature layer to the map
                MyMapView.Map.Layers.Add(flayer);
                ShapefileInfo.DataContext = flayer;
                ShapefileInfo.Visibility  = Visibility.Visible;
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
                ShapefileInfo.Visibility = Visibility.Collapsed;
            }
        }
Esempio n. 3
0
        private async Task LoadPolygonShapefile(string path)
        {
            ShapefileTable shapefile = await ShapefileTable.OpenAsync(path);

            var flayer = new FeatureLayer(shapefile);

            flayer.DisplayName = "面图层";
            flayer.ID          = "PolygonLayer";
            SpatialReference sp = flayer.DefaultSpatialReference;

            scene.Layers.Add(flayer);
        }
        private async Task <LayerData> OpenLayerAsync(string fullPath)
        {
            var table = await ShapefileTable.OpenAsync(fullPath);

            var layer = new FeatureLayer(table)
            {
                ID           = table.Name,
                DisplayName  = table.Name,
                FeatureTable = table
            };
            LayerData layerData = new LayerData()
            {
                Layer = layer,
                Name  = table.Name
            };

            return(layerData);
        }