ArcGIS for Android 100.3.0(2):入门案例

上篇介绍了开发环境的配置,现在就写个入门案例

布局文件:

  <com.esri.arcgisruntime.mapping.view.MapView
        android:id="@+id/mapview"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </com.esri.arcgisruntime.mapping.view.MapView>

代码:

public class Main1Activity extends AppCompatActivity {

    private MapView mMapView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main1);

        mMapView = (MapView) findViewById(R.id.mapview);

        /**
         * 参数1:Basemap.Type:底图类型
         * 参数2:形成地图中心点的初始视点的纬度
         * 参数3:形成地图中心点的初始视点的经度
         * 参数4:转换为初始Viewpoint的比例的详细程度。0是缩小最多的级别。
         */
        ArcGISMap map = new ArcGISMap(Basemap.Type.TOPOGRAPHIC, 34.056295, -117.195800, 16);
        // set the map to be displayed in this view
        mMapView.setMap(map);
    }

    @Override
    protected void onPause() {
        super.onPause();
        mMapView.pause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mMapView.resume();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mMapView.dispose();
    }
}

效果图:

这里写图片描述

Basemap.Type:底图类型

可查看api具体有哪些地图类型

https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/mapping/Basemap.Type.html

Arcgis内置的一些地图


        ArcGISMap arcGISMap1 = new ArcGISMap(Basemap.createStreets());
        ArcGISMap arcGISMap2 = new ArcGISMap(Basemap.createImagery());
        ArcGISMap arcGISMap3 = new ArcGISMap(Basemap.createStreetsVector());

        ArcGISMap arcGISMap4 = new ArcGISMap(Basemap.createTopographic());

        //初始化可见区域
        Envelope targetExtent = new Envelope(-13639984.0, 4537387.0, -13606734.0, 4558866.0,
                SpatialReferences.getWebMercator());
        Viewpoint initViewpoint = new Viewpoint(targetExtent);
        arcGISMap4.setInitialViewpoint(initViewpoint);

        mMapView.setMap(arcGISMap4);

猜你喜欢

转载自blog.csdn.net/qq_36699930/article/details/82386461