ArcGIS Android SDK-100.1.0 Offline downloaded map edit and sync

159 views Asked by At

I am surprised that ArcGIS provided all the tutorial docs for iOS but not for Android. Here I have got the iOS sample which I want -

Offline edit and Sync in iOS

but there are no tutorial for Android. Though I am able to download ArcGIS online map and show as a offline by the following code-

@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();
}

After that I would like to edit the offline and online map and sync the data when network is available but unfortunately I am not able to do that. Please help me in this scenario .

0

There are 0 answers