POST
|
At the following line in the sample code Generate Geodatabase—ArcGIS Runtime SDK for Android | ArcGIS for Developers: GenerateGeodatabaseParameters parameters = defaultParameters.get(); E/MainActivity: Error generating geodatabase parameters : com.esri.arcgisruntime.io.JsonEmbeddedException: Token Required
... View more
04-19-2018
07:34 PM
|
0
|
0
|
504
|
POST
|
Hello, I am trying to download a map for offline use but am running into trouble with generating the parameters as per this error I get (I have included my code also): @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_offline);
// inflate MapView from layout
aMapView = (MapView) findViewById(R.id.mapView);
map = new ArcGISMap(Basemap.Type.LIGHT_GRAY_CANVAS_VECTOR, 48.6596, -113.7870, 9);
aMapView.setMap(map);
// create a graphics overlay and symbol to mark the extent
mGraphicsOverlay = new GraphicsOverlay();
aMapView.getGraphicsOverlays().add(mGraphicsOverlay);
mProgressLayout = (RelativeLayout) findViewById(R.id.progressLayout);
final ProgressBar progressBar = (ProgressBar) findViewById(R.id.taskProgressBar);
mProgressTextView = (TextView) findViewById(R.id.progressTextView);
// get the callout that shows attributes
//aCallout = aMapView.getCallout();
// layer 0, facilities
table0 = new ServiceFeatureTable(getResources().getString(R.string.layer0_url));
final FeatureLayer featureLayer0 = new FeatureLayer(table0);
map.getOperationalLayers().add(featureLayer0);
// get the callout that shows attributes
//aCallout = aMapView.getCallout();
// layer 1, trails
table1 = new ServiceFeatureTable(getResources().getString(R.string.layer1_url));
final FeatureLayer featureLayer1 = new FeatureLayer(table1);
map.getOperationalLayers().add(featureLayer1);
// create a graphics overlay and symbol to mark the extent
final GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
aMapView.getGraphicsOverlays().add(graphicsOverlay);
final SimpleLineSymbol boundarySymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.RED, 5);
final Button startdownload = (Button) findViewById(R.id.startdownload);
// create a geodatabase sync task
final GeodatabaseSyncTask geodatabaseSyncTask = new GeodatabaseSyncTask(getString(R.string.glacier_sync));
geodatabaseSyncTask.loadAsync();
geodatabaseSyncTask.addDoneLoadingListener(() -> {
// generate the geodatabase sync task
startdownload.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
// show the progress layout
progressBar.setProgress(0);
mProgressLayout.setVisibility(View.VISIBLE);
// clear any previous operational layers and graphics if button clicked more than once
map.getOperationalLayers().clear();
graphicsOverlay.getGraphics().clear();
// show the extent used as a graphic
Envelope extent = aMapView.getVisibleArea().getExtent();
Graphic boundary = new Graphic(extent, boundarySymbol);
graphicsOverlay.getGraphics().add(boundary);
// create generate geodatabase parameters for the current extent
final ListenableFuture<GenerateGeodatabaseParameters> defaultParameters = geodatabaseSyncTask
.createDefaultGenerateGeodatabaseParametersAsync(extent);
defaultParameters.addDoneListener(new Runnable() {
@Override public void run() {
try {
// set parameters and don't include attachments
******* GenerateGeodatabaseParameters parameters = defaultParameters.get();
// set the sync model to per layer
parameters.setSyncModel(SyncModel.PER_LAYER);
// define the layers and features to include
int facilities = 1;
int trails = 3;
// Clear and re-create the layer options
parameters.getLayerOptions().clear();
parameters.getLayerOptions().add(new GenerateLayerOption(facilities));
parameters.getLayerOptions().add(new GenerateLayerOption(trails));
parameters.setReturnAttachments(false);
/*
// define the local path where the geodatabase will be stored
final String localGeodatabasePath =
getCacheDir().toString() + File.separator + getString(R.string.file_name);
// create and start the job
final GenerateGeodatabaseJob generateGeodatabaseJob = geodatabaseSyncTask
.generateGeodatabaseAsync(parameters, localGeodatabasePath);
generateGeodatabaseJob.start();
mProgressTextView.setText(getString(R.string.progress_started));
// update progress
generateGeodatabaseJob.addProgressChangedListener(() -> {
progressBar.setProgress(generateGeodatabaseJob.getProgress());
mProgressTextView.setText(getString(R.string.progress_fetching));
});
// get geodatabase when done
generateGeodatabaseJob.addJobDoneListener(new Runnable() {
@Override public void run() {
mProgressLayout.setVisibility(View.INVISIBLE);
if (generateGeodatabaseJob.getStatus() == Job.Status.SUCCEEDED) {
final Geodatabase geodatabase = generateGeodatabaseJob.getResult();
geodatabase.loadAsync();
geodatabase.addDoneLoadingListener(new Runnable() {
@Override public void run() {
if (geodatabase.getLoadStatus() == LoadStatus.LOADED) {
mProgressTextView.setText(getString(R.string.progress_done));
for (GeodatabaseFeatureTable geodatabaseFeatureTable : geodatabase
.getGeodatabaseFeatureTables()) {
geodatabaseFeatureTable.loadAsync();
map.getOperationalLayers().add(new FeatureLayer(geodatabaseFeatureTable));
}
startdownload.setVisibility(View.GONE);
Log.i(TAG, "Local geodatabase stored at: " + localGeodatabasePath);
} else {
Log.e(TAG, "Error loading geodatabase: " + geodatabase.getLoadError().getMessage());
}
}
});
// unregister since we're not syncing
ListenableFuture unregisterGeodatabase = geodatabaseSyncTask
.unregisterGeodatabaseAsync(geodatabase);
unregisterGeodatabase.addDoneListener(new Runnable() {
@Override public void run() {
Log.i(TAG, "Geodatabase unregistered since we wont be editing it in this sample.");
Toast.makeText(OfflineActivity.this,
"Geodatabase unregistered since we wont be editing it in this sample.",
Toast.LENGTH_LONG).show();
}
});
} else if (generateGeodatabaseJob.getError() != null) {
Log.e(TAG, "Error generating geodatabase: " + generateGeodatabaseJob.getError().getMessage());
} else {
Log.e(TAG, "Unknown Error generating geodatabase");
}
}
});*/
} catch (InterruptedException | ExecutionException e) {
Log.e(TAG, "Error generating geodatabase parameters : " + e.getMessage());
}
}
});
}
});
});
}
E/CRGdb: Error generating geodatabase parameters : com.esri.arcgisruntime.ArcGISRuntimeException: Invalid response
*******I have commented out portions of the code because it was returning this error each time and I wanted to know when it began (apparently it was after this line: GenerateGeodatabaseParameters parameters = defaultParameters.get();
... View more
04-19-2018
04:44 PM
|
0
|
1
|
598
|
POST
|
Thank you so much for your responses to my questions! I am implementing that sample code for creating an offline layer now but am running into some issues with getting the default parameters for generating the geodatabase. Android Studio throws an error that there is an Invalid response around this chunk of code (createOfflineData() is declared last in the onCreate() method for this class (OfflineActivity.java): private static void createOfflineData() {
// create a new GeodatabaseSyncTask to create a local version of feature service data
String featureServiceUrl = "https://services8.arcgis.com/UT5WPtsyyxzDrV2P/ArcGIS/rest/services/GNP_Fields/FeatureServer";
final GeodatabaseSyncTask gdbSyncTask = new GeodatabaseSyncTask(featureServiceUrl);
// define an extent for the features to include
Envelope extent = aMapView.getCurrentViewpoint(Viewpoint.Type.BOUNDING_GEOMETRY).getTargetGeometry().getExtent();
// get the default parameters for generating a geodatabase
ListenableFuture<GenerateGeodatabaseParameters> generateGdbParamsFuture = gdbSyncTask.createDefaultGenerateGeodatabaseParametersAsync(extent);
generateGdbParamsFuture.addDoneListener(() -> {
try {
GenerateGeodatabaseParameters generateGdbParams = generateGdbParamsFuture.get();
// set the sync model to per layer *********OfflineActivity.java:89 is here********
generateGdbParams.setSyncModel(SyncModel.PER_LAYER);
.
.
.
W/System.err: java.util.concurrent.ExecutionException: com.esri.arcgisruntime.ArcGISRuntimeException: Invalid response
W/System.err: at com.esri.arcgisruntime.internal.a.b.get(SourceFile:128)
W/System.err: at com.example.corac.gnp_labels.OfflineActivity.lambda$createOfflineData$2$OfflineActivity(OfflineActivity.java:89)
... View more
04-17-2018
03:13 PM
|
0
|
0
|
543
|
POST
|
Thanks for your response! I have found that it oddly zooms to it anyway (though there appears to be no code that does this in the sample).
... View more
04-17-2018
03:03 PM
|
0
|
0
|
491
|
POST
|
Hello, here is what my code in my onCreate method looks like now (I am following the code found on the Create an offline map guide page). I am using a button to begin the downloading process...I am confused because I do not find that the map is downloaded in the Downloads folder -- this code doesn't do anything but display my portal item: @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_offline);
// inflate MapView from layout
aMapView = (MapView) findViewById(R.id.mapView);
// get the portal url for ArcGIS Online
aPortal = new Portal(getResources().getString(R.string.portal_url));
// get the pre-defined portal id and portal url
aPortalItem = new PortalItem(aPortal, getResources().getString(R.string.webmap_glacier_national_park_id));
// create a map from a PortalItem
map = new ArcGISMap(aPortalItem);
// set the map to be displayed in this view
aMapView.setMap(map);
Log.d("MAP SET", "we have set our map!"); final Button startdownload = (Button) findViewById(R.id.startdownload);
startdownload.setOnClickListener(v -> { // create an offline map task
OfflineMapTask offlineMapTask = new OfflineMapTask(map);
//get all of the preplanned map areas in the web map
ListenableFuture<List<PreplannedMapArea>> mapAreasFuture = offlineMapTask.getPreplannedMapAreasAsync();
mapAreasFuture.addDoneListener(() -> {
try {
// get the list of areas
List<PreplannedMapArea> mapAreas = mapAreasFuture.get();
// loop through the map areas
for (PreplannedMapArea mapArea : mapAreas) {
// load each map area
mapArea.loadAsync();
// create the job
DownloadPreplannedOfflineMapJob downloadJob =
offlineMapTask.downloadPreplannedOfflineMap(mapArea, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString());
//start the job
downloadJob.start();
// listen for job complete
downloadJob.addJobDoneListener(() -> {
// get the download result
DownloadPreplannedOfflineMapResult downloadResult = downloadJob.getResult();
// check for errors
if (downloadResult.hasErrors()) {
// code here to examine errors:
Map<Layer, ArcGISRuntimeException> layerErrors = downloadResult.getLayerErrors();
Map<FeatureTable, ArcGISRuntimeException> tableErrors = downloadResult.getTableErrors();
} else {
// no errors so use the map straight away
map = downloadResult.getOfflineMap();
}
});
mapArea.addDoneLoadingListener(() -> {
// get the map area geometry so the is can used to display a graphic on the map
Geometry areaGeometry = mapArea.getAreaOfInterest();
// get the area title so it can be used in a UI component
String areaTitle = mapArea.getPortalItem().getTitle();
// UI code for showing map areas goes here:
});
}
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
});
});
}
... View more
04-16-2018
02:35 PM
|
1
|
1
|
576
|
POST
|
It seems that all of the map objects that can be used to download a map are constructed using PortalItems in the Create an offline map guide. Is there a way to download a map to view offline using the Services pattern that is from a hosted feature service? Am I misreading the fact that you can allow feature service data to be downloaded, edited, and changes synchronized? Also, when you view the map you have dowloaded offline, can you still enable popups to display the attributes of the features?
... View more
04-15-2018
06:37 PM
|
0
|
2
|
682
|
POST
|
Using the "Feature layer selection" sample code, how does the zoom-in work where when I select a feature, it zooms to it a certain odd way? Is this part of the Envelope?
... View more
04-11-2018
10:55 PM
|
0
|
2
|
623
|
POST
|
So it looks like I have changed the Alias but the original name for the field cannot change unless you create a new field with a new name and copy the old data to that field.
... View more
04-09-2018
06:30 PM
|
0
|
2
|
1073
|
POST
|
I am unfamiliar with this concept, what is the Alias and how can I change it?
... View more
04-06-2018
02:09 PM
|
0
|
4
|
1073
|
POST
|
Yes they show up fine online, just not in the app when I reference the service feature tables I have hosted online. I am showing the attributes in a popup but for some reason the fields have not been updated; other things have been updated though, like the size of the symbols, so I'm unsure why the fields are not updated too?
... View more
04-06-2018
12:13 AM
|
0
|
0
|
1073
|
POST
|
I used the "Display device location" sample code but would like to make it so that whenever the Spinner is on "Stop", the map is re-centered on the initial extent. How can I do this? I have tried so far in the switch statement for the "Stop" case this below, however it does not render the layers or basemap when it "zooms back" and I am confused: if (!mLocationDisplay.isStarted())
mLocationDisplay.startAsync();
// create the location point
Point centerPoint = new Point(48.6596, -113.7870, spatialReference);
// set the map views's viewpoint centered on Waterloo and scaled
aMapView.setViewpointCenterAsync(centerPoint, SCALE);
aMapView.resume();
break;
... View more
04-05-2018
09:42 PM
|
0
|
0
|
962
|
POST
|
I had edited the field names for two layers and then shared them as hosted feature services. The names are correctly changed on the Data description page on my ArcGIS Online content page however when I reference the feature service in my app to display the attributes, the fields are unchanged? How could this be?
... View more
04-05-2018
09:38 PM
|
0
|
8
|
1191
|
POST
|
Nope I do not! But that is interesting to know. I ended up recreating the layer in Arcmap using some better symbols I downloaded from the NPS site. My goal was to host the layer as a feature service so I wanted to upload it back online from ArcMap but since it would crash the program, I couldn't do that. Thanks for both of your help in this!
... View more
04-05-2018
02:08 PM
|
0
|
0
|
224
|
POST
|
Since I cannot save a layer file in a gdb, I have created two representations for two feature classes. I don't know what to do after "Convert Symbology to Representation". Now that I have created the representations, am I supposed to save the representations in the gdb along with their respective feature classes? How do I do this? I want to be able to publish the gdb as a hosted service on ArcGIS Online.
... View more
04-04-2018
05:08 PM
|
0
|
1
|
746
|
POST
|
Okay, yeah I hosted the feature layer with the original data.
... View more
04-04-2018
02:49 PM
|
0
|
0
|
969
|
Title | Kudos | Posted |
---|---|---|
1 | 01-31-2018 01:12 PM | |
2 | 01-31-2018 01:13 PM | |
1 | 10-10-2017 12:17 PM | |
1 | 10-10-2017 12:49 PM | |
1 | 04-16-2018 02:35 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|