private void BuildViewpoints() { _viewpoints.Add(Viewpoint.FromJson("{\"rotation\":0,\"scale\":1000,\"targetGeometry\":{\"x\":262285,\"y\":6652464.5,\"spatialReference\":{\"wkid\":25833}}}")); _viewpoints.Add(Viewpoint.FromJson("{\"rotation\":0,\"scale\":20000,\"targetGeometry\":{\"x\":253315,\"y\":6654300,\"spatialReference\":{\"wkid\":25833}}}")); _viewpoints.Add(Viewpoint.FromJson("{\"rotation\":0,\"scale\":1815,\"targetGeometry\":{\"x\":262160,\"y\":6649608,\"spatialReference\":{\"wkid\":25833}}}")); _viewpoints.Add(Viewpoint.FromJson("{\"rotation\":0,\"scale\":58017,\"targetGeometry\":{\"x\":269672.5,\"y\":6649969,\"spatialReference\":{\"wkid\":25833}}}")); _viewpoints.Add(Viewpoint.FromJson("{\"rotation\":0,\"scale\":3882,\"targetGeometry\":{\"x\":265936,\"y\":6648557,\"spatialReference\":{\"wkid\":25833}}}")); _viewpoints.Add(Viewpoint.FromJson("{\"rotation\":0,\"scale\":5202,\"targetGeometry\":{\"x\":472844,\"y\":7381382,\"spatialReference\":{\"wkid\":25833}}}")); _viewpoints.Add(Viewpoint.FromJson("{\"rotation\":0,\"scale\":19758,\"targetGeometry\":{\"x\":463790,\"y\":7569163,\"spatialReference\":{\"wkid\":25833}}}")); _viewpoints.Add(Viewpoint.FromJson("{\"rotation\":0,\"scale\":2155,\"targetGeometry\":{\"x\":707583,\"y\":7765954,\"spatialReference\":{\"wkid\":25833}}}")); _viewpoints.Add(Viewpoint.FromJson("{\"rotation\":0,\"scale\":13759,\"targetGeometry\":{\"x\":-8894,\"y\":6577979,\"spatialReference\":{\"wkid\":25833}}}")); _viewpoints.Add(Viewpoint.FromJson("{\"rotation\":0,\"scale\":97361,\"targetGeometry\":{\"x\":34708,\"y\":6928132,\"spatialReference\":{\"wkid\":25833}}}")); _viewpoints.Add(Viewpoint.FromJson("{\"rotation\":0,\"scale\":11418,\"targetGeometry\":{\"x\":-24734,\"y\":6850905,\"spatialReference\":{\"wkid\":25833}}}")); _viewpoints.Add(Viewpoint.FromJson("{\"rotation\":0,\"scale\":3443,\"targetGeometry\":{\"x\":-31933,\"y\":6844529,\"spatialReference\":{\"wkid\":25833}}}")); _viewpoints.Add(Viewpoint.FromJson("{\"rotation\":0,\"scale\":51662,\"targetGeometry\":{\"x\":266348,\"y\":7036630,\"spatialReference\":{\"wkid\":25833}}}")); _viewpoints.Add(Viewpoint.FromJson("{\"rotation\":0,\"scale\":2771,\"targetGeometry\":{\"x\":243093,\"y\":7082664,\"spatialReference\":{\"wkid\":25833}}}")); _viewpoints.Add(Viewpoint.FromJson("{\"rotation\":0,\"scale\":1898,\"targetGeometry\":{\"x\":298397,\"y\":7138339,\"spatialReference\":{\"wkid\":25833}}}")); _viewpoints.Add(Viewpoint.FromJson("{\"rotation\":0,\"scale\":121294,\"targetGeometry\":{\"x\":483345,\"y\":7463257,\"spatialReference\":{\"wkid\":25833}}}")); }
public async void InitScene(string json, SceneView sceneView) { try { JsonReader jreader = new JsonTextReader(new System.IO.StringReader(json)); JObject jo = (JObject)JsonConvert.DeserializeObject(json); // 加载operationalLayers 图层 if (jo["operationalLayers"].Count() > 0) { int LayerCount = 1; for (int j = 0; j < jo["operationalLayers"].Count(); j++, LayerCount++) { string operational_title = jo["operationalLayers"][j]["title"].ToString(); string operational_layerType = jo["operationalLayers"][j]["layerType"].ToString(); if (operational_layerType.Equals("GroupLayer")) { if (jo["operationalLayers"][j]["layers"] != null && jo["operationalLayers"][j]["layers"].Count() > 0) { for (int i = 0; i < jo["operationalLayers"][j]["layers"].Count(); i++) { string GrouplLayers_title = jo["operationalLayers"][j]["layers"][i]["title"].ToString(); string GrouplLayers_url = jo["operationalLayers"][j]["layers"][i]["url"].ToString(); ArcGISSceneLayer Scenelayer = new ArcGISSceneLayer(new Uri(GrouplLayers_url)); sceneView.Scene.OperationalLayers.Add(Scenelayer); //Label lab = new Label { Content = $"图层{LayerCount} : {GrouplLayers_title}" }; //this.listLayer.Items.Add(lab); } } } else { string operational_url = jo["operationalLayers"][j]["url"].ToString(); ArcGISSceneLayer Scenelayer = new ArcGISSceneLayer(new Uri(operational_url)); sceneView.Scene.OperationalLayers.Add(Scenelayer); //Label lab = new Label { Content = $"图层{LayerCount} : {operational_title}" }; //this.listLayer.Items.Add(lab); } } } if (jo["baseMap"]["baseMapLayers"] != null && jo["baseMap"]["baseMapLayers"].Count() > 0) { // 加载底图 baseMap string baseMapLayers_layerType = jo["baseMap"]["baseMapLayers"][0]["layerType"].ToString(); if (baseMapLayers_layerType.Equals("ArcGISTiledMapServiceLayer")) { string baseMapLayers_url = jo["baseMap"]["baseMapLayers"][0]["url"].ToString(); ArcGISMapImageLayer basemap = new ArcGISMapImageLayer(new Uri(baseMapLayers_url)); Basemap map = new Basemap(basemap); sceneView.Scene.Basemap = map; } } // 加载高程 elevationLayers if (jo["baseMap"]["elevationLayers"] != null && jo["baseMap"]["elevationLayers"].Count() > 0) { for (int j = 0; j < jo["baseMap"]["elevationLayers"].Count(); j++) { string elevationLayer_url = jo["baseMap"]["elevationLayers"][j]["url"].ToString(); string elevationLayer_layerType = jo["baseMap"]["elevationLayers"][j]["layerType"].ToString(); var elevationSource = new ArcGISTiledElevationSource(new System.Uri(elevationLayer_url)); sceneView.Scene.BaseSurface.ElevationSources.Add(elevationSource); } } // 加载书签 slides if (jo["presentation"]["slides"] != null && jo["presentation"]["slides"].Count() >= 0) { int bookMarkCount = 1; for (int j = 0; j < jo["presentation"]["slides"].Count(); j++, bookMarkCount++) { string sttt = JsonConvert.SerializeObject(jo["presentation"]["slides"][j]["viewpoint"]); string bkname = jo["presentation"]["slides"][j]["title"]["text"].ToString(); string bkimage = jo["presentation"]["slides"][j]["thumbnail"]["url"].ToString(); Viewpoint vp = Viewpoint.FromJson(sttt); Bookmark bk = new Bookmark(bkname, vp); sceneView.Scene.Bookmarks.Add(bk); // Camera ca = new Camera(); // Label lab = new Label { Content = $"书签{bookMarkCount} : {bkname}" }; //lab.Tag = vp; //lab.MouseDown += Lab_MouseDown; // this.listbookMark.Items.Add(lab); //double slidesx = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["x"]; //double slidesy = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["y"]; //double slidesz = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["position"]["z"]; //double slides_heading = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["heading"]; //double slides_tilt = (double)jo["presentation"]["slides"][j]["viewpoint"]["camera"]["tilt"]; } } string initialState = JsonConvert.SerializeObject(jo["initialState"]["viewpoint"]); Viewpoint initialViewpoint = Viewpoint.FromJson(initialState); await sceneView.SetViewpointAsync(initialViewpoint, TimeSpan.FromSeconds(10)); } catch { } }