SceneVIEw
Runtime100是用了一个GeoVIEw类作为地图的基类直接继承于VIEwGroup,然后MapVIEw和SceneVIEw分别作为二维和三维地图的容器继承于GeoVIEw。
其实把SceneVIEw当做MapVIEw,把ArcGISScene当做ArcGISMap就行,于是我们简单尝试下。首先是在XML文件里添加SceneVIEw:
<com.esri.arcgisruntime.mapPing.vIEw.SceneVIEw androID:ID="@+ID/scenevIEw" androID:layout_wIDth="match_parent" androID:layout_height="match_parent"> </com.esri.arcgisruntime.mapPing.vIEw.SceneVIEw>
public class SceneVIEwActivity extends AppCompatActivity { private SceneVIEw mSceneVIEw; @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_scene_vIEw); mSceneVIEw = (SceneVIEw) findVIEwByID(R.ID.scenevIEw); ArcGISScene arcGISScene = new ArcGISScene(); mSceneVIEw.setScene(arcGISScene); } @OverrIDe protected voID onResume() { super.onResume(); mSceneVIEw.resume(); } @OverrIDe protected voID onPause() { super.onPause(); mSceneVIEw.pause(); } @OverrIDe protected voID onDestroy() { super.onDestroy(); mSceneVIEw.dispose(); }}
运行下,看看效果:
可以看出其实SceneVIEw的基本底图就是一个地球,然后我们给它设置个瓦片图层作为底图:
mSceneVIEw = (SceneVIEw) findVIEwByID(R.ID.scenevIEw); ArcGISScene arcGISScene = new ArcGISScene(); ArcGISTiledLayer arcGISTiledLayer = new ArcGISTiledLayer( "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"); Basemap basemap = new Basemap(arcGISTiledLayer); arcGISScene.setBasemap(basemap); mSceneVIEw.setScene(arcGISScene);
可以看出这其实就是把一个切片图层展示在地球上,可以进行三维 *** 作而已。
展示三维场景(ArcGISScene)
三维通过接近真实世界的角度来可视化数据信息
三维场景的使用类似于MapVIEw和ArcGISMap,二维数据皆可加入三维场景
三维场景不同于二维,其具备高程表面(elevation surface)
无高程表面(elevation surface)
private SceneVIEw mSceneVIEw; private String brest_buildings = " http://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Brest/Sceneserver"; @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_scene_layer); mSceneVIEw = (SceneVIEw) findVIEwByID(R.ID.sceneVIEw); ArcGISScene scene = new ArcGISScene(); scene.setBasemap(Basemap.createImagery()); mSceneVIEw.setScene(scene); // add a scene service to the scene for vIEwing buildings ArcGISSceneLayer sceneLayer = new ArcGISSceneLayer(brest_buildings); scene.getoperationalLayers().add(sceneLayer); // 设置三维场景视角镜头(camera) Camera camera = new Camera(48.378, -4.494, 200, 345, 65, 0); mSceneVIEw.setVIEwpointCamera(camera); }
使用高程表面(ArcGISTiledElevationSource、RasterElevationSource)
ArcGISTiledElevationSource:将在线服务作为高程表面
RasterElevationSource:将本地DEM文件作为高程表面
private SceneVIEw mSceneVIEw; private String elevation_image_service = "http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"; @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_display_scene); mSceneVIEw = (SceneVIEw) findVIEwByID(R.ID.sceneVIEw); ArcGISScene scene = new ArcGISScene(); scene.setBasemap(Basemap.createImagery()); mSceneVIEw.setScene(scene); ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(elevation_image_service); scene.getBaseSurface().getElevationSources().add(elevationSource); Camera camera = new Camera(28.4, 83.9, 10010.0, 10.0, 80.0, 0.0); mSceneVIEw.setVIEwpointCamera(camera); }
设置三维场景视角镜头(camera)纬度(Latitude)、经度(longitude)和高程(elevation)heading:镜头水平朝向0度表示指北,从0度逐渐增加,镜头顺时针旋转,360度回到0度指北。Pitch:镜头垂直朝向0度表示垂直俯视地球,从0度逐渐增加,镜头沿其水平朝向,从俯视地球朝天空旋转,360度回到0度俯视地球。 public Camera(double latitude, double longitude, double altitude, double heading, double pitch, double roll)
表面置放模式(LayerScenePropertIEs.SurfacePlacement)
与二维不同的是,通过GraphicsOverlay添加空间要素时,需要设置表面置放模式,默认为DRAPED。
DRAPED:空间要素紧贴场景表面(surface layer),不考虑空间要素的高程值(Z-values)
absolute:空间要素通过其高程值(Z-values)设置距离球体表面(海平面)的高度
relative:空间要素通过其高程值(Z-values)设置距离场景表面(surface layer)的高度
球体表面和场景表面的差异在于是否使用高程表面,若不使用高程表面absolute和relative在三维场景中展示的位置相同。
private SceneVIEw mSceneVIEw; private String elevation_image_service = "http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"; @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_surfac_placement); mSceneVIEw = (SceneVIEw) findVIEwByID(R.ID.sceneVIEw); // create a scene and add a basemap to it ArcGISScene agsScene = new ArcGISScene(); agsScene.setBasemap(Basemap.createImagery()); mSceneVIEw.setScene(agsScene); // add base surface for elevation data ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(elevation_image_service); agsScene.getBaseSurface().getElevationSources().add(elevationSource); // add a camera and initial camera position Camera camera = new Camera(53.04, -4.04, 1300, 0, 90.0, 0); mSceneVIEw.setVIEwpointCamera(camera); // create overlays with elevation modes GraphicsOverlay drapedOverlay = new GraphicsOverlay(); drapedOverlay.getScenePropertIEs().setSurfacePlacement(LayerScenePropertIEs.SurfacePlacement.DRAPED); mSceneVIEw.getGraphicsOverlays().add(drapedOverlay); GraphicsOverlay relativeOverlay = new GraphicsOverlay(); relativeOverlay.getScenePropertIEs().setSurfacePlacement(LayerScenePropertIEs.SurfacePlacement.relative); mSceneVIEw.getGraphicsOverlays().add(relativeOverlay); GraphicsOverlay absoluteOverlay = new GraphicsOverlay(); absoluteOverlay.getScenePropertIEs().setSurfacePlacement(LayerScenePropertIEs.SurfacePlacement.absolute); mSceneVIEw.getGraphicsOverlays().add(absoluteOverlay); // create point for graphic location Point point = new Point(-4.04, 53.06, 1000, camera.getLocation().getSpatialReference()); // create a red (0xFFFF0000) circle symbol SimpleMarkerSymbol circleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, 0xFFFF0000, 10); // create a text symbol for each elevation mode TextSymbol drapedText = new TextSymbol(10, "DRAPED", 0xFFFFFFFF, TextSymbol.HorizontalAlignment.left, TextSymbol.VerticalAlignment.MIDDLE); TextSymbol relativeText = new TextSymbol(10, "relative", 0xFFFFFFFF, TextSymbol.HorizontalAlignment.left, TextSymbol.VerticalAlignment.MIDDLE); TextSymbol absoluteText = new TextSymbol(10, "absolute", 0xFFFFFFFF, TextSymbol.HorizontalAlignment.left, TextSymbol.VerticalAlignment.MIDDLE); // add the point graphic and text graphic to the corresponding graphics // overlay drapedOverlay.getGraphics().add(new Graphic(point, circleSymbol)); drapedOverlay.getGraphics().add(new Graphic(point, drapedText)); relativeOverlay.getGraphics().add(new Graphic(point, circleSymbol)); relativeOverlay.getGraphics().add(new Graphic(point, relativeText)); absoluteOverlay.getGraphics().add(new Graphic(point, circleSymbol)); absoluteOverlay.getGraphics().add(new Graphic(point, absoluteText)); }
Portalitem
mSceneVIEw = findVIEwByID(R.ID.sceneVIEw); // get the portal url and portal item from ArcGIS online Portal portal = new Portal("http://www.arcgis.com/", false); Portalitem portalitem = new Portalitem(portal, "a13c3c3540144967bc933cb5e498b8e4"); ArcGISScene scene = new ArcGISScene(portalitem); mSceneVIEw.setScene(scene);
三维场景中的可视化
三维场景(SceneVIEw 、ArcGISScene)中具备更多的符号化方式来传递信息,包括SimpleMarkerScenesymbol、ModelMarkerSymbol、distanceCompositeScenesymbol以及空间要素拉伸。
总结以上是内存溢出为你收集整理的安卓智能地图开发:展示三维场景 - ArcGIS Runtime SDK for Android全部内容,希望文章能够帮你解决安卓智能地图开发:展示三维场景 - ArcGIS Runtime SDK for Android所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)