其他分享
首页 > 其他分享> > ArcGIS for Android 基础入门案例(代码部分)

ArcGIS for Android 基础入门案例(代码部分)

作者:互联网

ARCGIS FOR ANDROID 100.3.0:入门案例

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

布局文件:

  <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);
破z晓 发布了4 篇原创文章 · 获赞 3 · 访问量 2117 私信 关注

标签:入门,Type,void,ArcGIS,ArcGISMap,new,Android,Basemap,mMapView
来源: https://blog.csdn.net/qq_19688207/article/details/104550624