arcgis for android 气泡,简单易用的ArcGIS runtime for Android 10.2

(1)更简单的调用云GIS(ArcGIS Online)上的数据

以前我们调用ArcGIS Online上的地图,需要知道底图的URL地址:

name="WORLD_STREET_MAP">http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer

name="WORLD_TOPO_MAP">http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer

name="WORLD_NATGEO_MAP">http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer

name="OCEAN_BASEMAP">http://services.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer

同时在代码中调用该服务地址:

//create an initial basemap

basemapStreet = new

ArcGISTiledMapServiceLayer(this.getResources()

.getString(R.string.WORLD_STREET_MAP));

// Add basemap to MapView

mMapView.addLayer(basemapStreet);

// set visibility

basemapStreet.setVisible(true);

如果需要更改底图,我们需要以下代码:

basemapTopo = new

ArcGISTiledMapServiceLayer(this.getResources()

.getString(R.string.WORLD_TOPO_MAP));

mMapView.addLayer(basemapTopo);

basemapStreet.setVisible(false);

basemapTopo.setVisible(true);

如果采用ArcGIS runtime for Android 10.2,这一切就更简单了。

首先,你不一定要记得arcgis online上的服务地址了,用MapOptions就能轻松搞定。

在xml文档中我们可以简单的配置下:

android:id="@+id/map"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

mapoptions.MapType="topo"

mapoptions.ZoomLevel="13"

mapoptions.center="33.666354, -117.903557"/>

然后在代码中简单的一句:

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

当然我们可以很简单就修改底图和范围:

MapOptions streets = new MapOptions(MapType.STREETS);

mMapView.setMapOptions(streets);

(2)简单的标签

之前我们实现graphic的标签和气泡功能,需要PopupInfo和PictureMarkerSymbol,整个过程还是比较复杂,但是我们用了arcgis

runtime for android 10.2的ArcGIS Android Application

Framework,就能轻松实现。

第一步引用ArcGIS Android

Application Framework,右键项目,选择“ArcGIS Tools”,然后选择“add Application

Framework to project”,如下图所示:

a4c26d1e5885305701be709a3d33442f.png

然后在项目中就可以看到引用的库文件了

a4c26d1e5885305701be709a3d33442f.png

第二步,写入代码,如下所示:

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

// Create a MapView Helper

mvHelper = new MapViewHelper(mMapView);

// Create drawable icon

icon =

getResources().getDrawable(R.drawable.route_destination);

// Make sure map has loaded before adding geometries

mMapView.setOnStatusChangedListener(new OnStatusChangedListener()

{

private static final long serialVersionUID =

1L;

public void onStatusChanged(Object source,

STATUS status) {

// Add a

graphic to represent ESRI Headquarters

int loaded =

mvHelper.addMarkerGraphic(34.056695, -117.195693,

"ESRI", "World Headquarters", null, icon, false, 0);

if (loaded

< 0) {

Log.d("TAG", "Marker Graphic not added to MapView");

}

}

});

实现效果如下图所示;

a4c26d1e5885305701be709a3d33442f.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值