我很惊讶ArcGIS提供了iOS的所有教程文档,但没有为Android提供。在这里,我有我想要的iOS样本 -
但没有针对Android的教程。虽然我可以通过以下代码下载ArcGIS在线地图并显示为离线 -
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mMapView = (MapView) findViewById(R.id.mapView);
imageButton = (ImageButton) findViewById(R.id.imageButton);
onlineBtn = (Button) findViewById(R.id.onlineBtn);
offlineBtn = (Button) findViewById(R.id.offlineBtn);
/*ArcGISMap map = new ArcGISMap(Basemap.Type.IMAGERY_WITH_LABELS_VECTOR, 34.056295, -117.195800, 16);
mMapView.setMap(map);*/
showOnlineMap();
offlineBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LoadOfflineMap loadOffline = new LoadOfflineMap(mMapView, map, tiledLayer, geodatabase, MainActivity.this);
loadOffline.loadOfflineMap();
}
});
onlineBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showOnlineMap();
//startActivity(new Intent(MainActivity.this, OfflineGeocodeActivity.class));
}
});
}
private void showOnlineMap() {
//--- create new Tiled Layer from service url
tiledLayer = new ArcGISTiledLayer("https://sampleserver6.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer");
//--- set tiled layer as basemap
Basemap basemap = new Basemap(tiledLayer);
//--- create a map with the basemap
map = new ArcGISMap(basemap);
map.setInitialViewpoint(new Viewpoint(37.7749, -122.4194, 1));
//--- set the map to be displayed in this view
mMapView.setMap(map);
// this.addFeatureLayersFromURL(“https://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/”); this.addFeatureLayersFromURL( “https://sampleserver6.arcgisonline.com/arcgis/rest/services/Sync/WildfireSync/FeatureServer/”);
imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DownloadMap dwnMap = new DownloadMap(syncTask,MainActivity.this,mMapView,geodatabase);
dwnMap.downloadMapOverlays();
}
});
/*final Button btnDownload = new Button(cordova.getActivity());
btnDownload.setText("Download");
btnDownload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Toast.makeText(cordova.getActivity(), "Download will start", Toast.LENGTH_LONG).show();
cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
progressDialog.setMessage("Request to server..");
progressDialog.show();
}
});
downloadMapOverlays();
}
});
cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
cordova.getActivity().addContentView(mapView, new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));
cordova.getActivity().addContentView(btnDownload, new LinearLayout.LayoutParams(500, 100));
}
});
Toast.makeText(cordova.getActivity(), message, Toast.LENGTH_LONG).show();
callbackContext.success(message);
} else {
Toast.makeText(cordova.getActivity(), "Plugin Error", Toast.LENGTH_LONG).show();
callbackContext.error("Expected one non-empty string argument.");
}*/
}
/****
* Add feature Layer on ArcGIS Map
* @param url
*/
private void addFeatureLayersFromURL(final String url) {
syncTask = new GeodatabaseSyncTask(url);
syncTask.loadAsync();
syncTask.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
for (int count = 0; count < syncTask.getFeatureServiceInfo().getLayerInfos().size(); count++) {
IdInfo layerInfo = syncTask.getFeatureServiceInfo().getLayerInfos().get(count);
String layerURL = url.concat(String.valueOf(count));
ServiceFeatureTable table = new ServiceFeatureTable(layerURL);
FeatureLayer layer = new FeatureLayer(table);
layer.setName(layerInfo.getName());
map.getOperationalLayers().add(layer);
}
}
});
}
@Override
protected void onPause(){
mMapView.pause();
super.onPause();
}
@Override
protected void onResume(){
super.onResume();
mMapView.resume();
}
之后我想编辑离线和在线地图,并在网络可用时同步数据,但不幸的是我无法做到这一点。请帮助我解决这个问题。