POST
|
I fixed this. Here is the code for who wants do the same. mapView.setOnSingleTapListener(new OnSingleTapListener() {
@Override
public void onSingleTap(float v, float v1) {
Point point = mapView.toMapPoint(v, v1);
new AsyncTaskDetalhePontoNoMapa(getURLTipoMapa(), point, mapView, arcGISDynamicMapServiceLayer.getSpatialReference(), isOutorga(), ActivityMapa.this).execute();
}
}); Finally, my asynctask: import android.os.AsyncTask;
import com.esri.android.map.MapView;
import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.Point;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.io.UserCredentials;
import com.esri.core.map.FeatureSet;
import com.esri.core.map.Graphic;
import com.esri.core.tasks.ags.query.Query;
import com.esri.core.tasks.ags.query.QueryTask;
import org.codehaus.jackson.map.ObjectMapper;
import app.i3systems.bramar.ffdc.interfaces.Listable;
import app.i3systems.bramar.ffdc.interfaces.PontoClicavel;
import app.i3systems.bramar.ffdc.model.Outorga;
import app.i3systems.bramar.ffdc.model.Poco;
import app.i3systems.bramar.ffdc.utils.Utils;
import app.i3systems.bramar.ffdc.utils.UtilsSharedPreferences;
/**
* Created by pedrofsn on 07-07-17.
*/
public class AsyncTaskDetalhePontoNoMapa extends AsyncTask<Point, Void, String> {
private Point clickPoint;
private double resolution;
private String url;
private SpatialReference spatialReference;
private boolean isOutorga;
private PontoClicavel callback;
public AsyncTaskDetalhePontoNoMapa(String url, Point clickPoint, MapView mapView, SpatialReference spatialReference, boolean isOutorga, PontoClicavel callback) {
this.url = url;
this.callback = callback;
this.isOutorga = isOutorga;
this.clickPoint = clickPoint;
this.spatialReference = spatialReference;
this.resolution = mapView.getResolution();
}
@Override
protected String doInBackground(Point... params) {
double tolerance = 100;
double resolutionWithTolerance = tolerance * resolution;
Envelope envelope = new Envelope(clickPoint, resolutionWithTolerance, resolutionWithTolerance);
try {
UserCredentials userCredentials = new UserCredentials();
userCredentials.setUserAccount(UtilsSharedPreferences.getLogin(), UtilsSharedPreferences.getSenha());
QueryTask queryTask = new QueryTask(url + "/0", userCredentials);
Query query = new Query();
query.setInSpatialReference(spatialReference);
query.setOutSpatialReference(spatialReference);
query.setGeometry(envelope);
query.setMaxFeatures(30);
query.setOutFields(new String[]{"*"});
FeatureSet featureSet = queryTask.execute(query);
Graphic[] resultGraphic = featureSet.getGraphics();
if (!Utils.isNullOrEmpty(resultGraphic) && resultGraphic.length > 0) {
ObjectMapper mapper = new ObjectMapper();
Listable listable = mapper.convertValue(resultGraphic[0].getAttributes(), isOutorga ? Outorga.class : Poco.class);
return listable.toString();
}
} catch (Exception e) {
e.printStackTrace();
}
Utils.log("Coordenadas : " + clickPoint.getX() + ", " + clickPoint.getY());
return null;
}
@Override
protected void onPostExecute(String string) {
super.onPostExecute(string);
callback.onDetalhesObtidosDoPontoNoMapa(clickPoint, string);
}
}
... View more
07-10-2017
06:42 AM
|
1
|
0
|
1010
|
POST
|
I tried a query and on web-query for tests purpose and it's working, like: http://is.bramar.net/arcgis/rest/services/SocioEconomics/OutrogasAESA_FS/FeatureServer/0/query?where=1+%3D+1&objectIds=&… In android it is not working. My code: [...] compile 'com.esri.arcgis.android:arcgis-android:10.2.9'
[...] featureLayer = new ArcGISFeatureLayer( "http://is.bramar.net/arcgis/rest/services/SocioEconomics/OutrogasAESA_FS/FeatureServer" , MODE.ONDEMAND); [...] and mapView.setOnSingleTapListener(new OnSingleTapListener() {
public void onSingleTap(float x, float y) {
Geometry geom = (GeometryEngine.buffer(pointClicked, mapView.getSpatialReference(), 100, null));
// build a query to select the clicked feature
Query query = new Query();
query.setOutFields(new String[]{"*"});
query.setSpatialRelationship(SpatialRelationship.ENVELOPE_INTERSECTS);
query.setGeometry(geom);
query.setInSpatialReference(mapView.getSpatialReference());
featureLayer.selectFeatures(query, ArcGISFeatureLayer.SELECTION_METHOD.NEW, new CallbackListener<FeatureSet>() {
// handle any errors
public void onError(Throwable e) {
Log.d(TAG, "Select Features Error" + e.getLocalizedMessage());
}
public void onCallback(FeatureSet queryResults) {
int size = 0;
if (!Utils.isNullOrEmpty(queryResults.getGraphics())) {
size = queryResults.getGraphics().length;
}
Utils.log("Size: " + size);
if (size > 0) {
Log.d(TAG, "Feature found id=" + queryResults.getGraphics()[0].getAttributeValue(featureLayer.getObjectIdField()));
// set new data and notify adapter that data has changed
listAdapter.setFeatureSet(queryResults);
listAdapter.notifyDataSetChanged();
// This callback is not run in the main UI thread. All GUI
// related events must run in the UI thread,
// therefore use the Activity.runOnUiThread() method. See
// http://developer.android.com/reference/android/app/Activity.html#runOnUiThread(java.lang.Runnable)
// for more information.
AttributeEditorActivity.this.runOnUiThread(new Runnable() {
public void run() {
// show the editor dialog.
showDialog(ATTRIBUTE_EDITOR_DIALOG_ID);
}
});
}
}
});
}
});
... View more
07-03-2017
01:16 PM
|
0
|
1
|
2088
|
POST
|
I've this piece of code: final ArcGISDynamicMapServiceLayer arcGISFeatureLayer = new ArcGISDynamicMapServiceLayer(URL, null, userCredentials); and my URL is SocioEconomics/OutorgaAESA (MapServer) . The map is showing good (like on attachment), but I can't figure out how can I can click on a specific point of map and display the features. On Google Maps SDK for Android I know a method like onMarkerClick(Marker marker...). But I didn't see anything like this on ArcGIS SDK (for took the info about the point, not just the latitude and longitude).
... View more
06-30-2017
01:15 PM
|
0
|
1
|
621
|
POST
|
My error happens inside: if (geodatabaseSyncTask.getLoadStatus() == LoadStatus.FAILED_TO_LOAD) { dealWithException(geodatabaseSyncTask.getLoadError()); } from Sync offline edits—ArcGIS Runtime SDK for Android | ArcGIS for Developers (method createGeodatabaseSyncTask()) So, I've tried to execute the method generateGeodatabaseParameters() before createGeodatabaseSyncTask() but I've got a excpetion with: Cause: Feature service is not loaded, it needs to be loaded before passed into the sync task. Message: Invalid access range How can I proceed?
... View more
05-31-2017
01:09 PM
|
0
|
0
|
502
|
POST
|
I changed the arcgis library, so the problem doesn't happen anymore.
... View more
05-31-2017
07:40 AM
|
0
|
0
|
1153
|
POST
|
05-31-2017
07:38 AM
|
0
|
0
|
1153
|
POST
|
I'm following this steps to sync a database, Sync offline edits—ArcGIS Runtime SDK for Android | ArcGIS for Developers . But I can't realize where I need to put the parameters [1] on android code [2]. And I think that I'm getting error on ArcGIS log because I'm not using this parameters right [3]. How can I fix this? See prints in attachment, please.
... View more
05-31-2017
07:37 AM
|
0
|
2
|
895
|
POST
|
When I run my app with com.esri.arcgis.android:arcgis-android:10.2.9 and mapView.addLayer(new ArcGISDynamicMapServiceLayer("http://geoservidor.minam.gob.pe/arcgis/rest/services/MAPA_FINAL_ACT_MINERA/MapServer")); I got Rejecting re-init on previously-failed class java.lang.Class<com.esri.core.internal.util.d>: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/codehaus/jackson/map/ObjectMapper; [...] Caused by: java.lang.ClassNotFoundException: Didn't find class "org.codehaus.jackson.map.ObjectMapper" on path: DexPathList[[zip file "/data/app/demo.spda.com.demo-1/base.apk", zip file "/data/app/demo.spda.com.demo-1/split_lib_dependencies_apk.apk", zip file "/data/app/demo.spda.com.demo-1/split_lib_slice_0_apk.apk", zip file "/data/app/demo.spda.com.demo-1/split_lib_slice_1_apk.apk", zip file "/data/app/demo.spda.com.demo-1/split_lib_slice_2_apk.apk", zip file "/data/app/demo.spda.com.demo-1/split_lib_slice_3_apk.apk", zip file "/data/app/demo.spda.com.demo-1/split_lib_slice_4_apk.apk", zip file "/data/app/demo.spda.com.demo-1/split_lib_slice_5_apk.apk", zip file "/data/app/demo.spda.com.demo-1/split_lib_slice_6_apk.apk", zip file "/data/app/demo.spda.com.demo-1/split_lib_slice_7_apk.apk", zip file "/data/app/demo.spda.com.demo-1/split_lib_slice_8_apk.apk", zip file "/data/app/demo.spda.com.demo-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/demo.spda.com.demo-1/lib/x86, /system/fake-lib Is it a problem with this ArcGIS version? I tried create other project and the problem coninues. But, if I downgrade the library version to 10.2.7, it works!
... View more
05-23-2017
07:53 AM
|
0
|
6
|
2146
|
Title | Kudos | Posted |
---|---|---|
1 | 07-10-2017 06:42 AM |