Select to view content in your preferred language

Android SDK Identify Sample?

783
6
11-29-2012 05:07 AM
TylerWaring
Frequent Contributor
Greetings,

I am just getting started with the Android SDK and am working through some of the samples. I have gotten to the Identify sample and am a little bit confused about what I am working with. I subsequently have a couple of questions that would help me in my mission.

Am I working with the correct version of the Identify sample? I am working with the samples that I downloaded with ArcGIS for Android 2.0.0. The help files for this sample (http://help.arcgis.com/en/arcgismobile/10.0/apis/android/help/#/Identify_task_sample/01190000001w000...) describe a scenario that explores recent earthquakes. However, when I build and run my sample I get a map of the 50 states. Is the earthquake scenario the most up to date and if so where do I get a working copy of the code for the earthquake scenario?

When I run the Identify sample and click on a state, the popup spinner always lists a state that is different than the state I clicked on. For instance, If I click on Texas, I get New Mexico in my popup. When I click on the spinner dropdown, I get a list with Texas and all of the nearby states. Is this the intended result? Is there any way to make the identify point more accurate? I would like to have only one result returned when I click on a state.

Lastly when I swap out the sample map service with a parcel service of my own, I am unable to get any results in the popup. I am swaping out the URLs in the following locaitons:

In onCreate:
  
ArcGISTiledMapServiceLayer layer = new ArcGISTiledMapServiceLaye("http://services.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Average_Household_Size/MapServer");
  
map.addLayer(layer);  


and in onPreExecute:

mIdentifyTask = new IdentifyTask("http://services.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Average_Household_Size/MapServer");


My service supports the Identify as a supported opperation. Is there something I am missing?


Any hints, tips or nudges in the right direction will be greatly appreciated.

Best Regards,
Tyler
0 Kudos
6 Replies
AaronNash1
Frequent Contributor
I have the same problem, can't seem to figure out the issue. The only differences between the sample and the service I am trying to identify is, my service is dynamic and the table is joined to another table. I was able to return results on a cached webservice. Not sure what would need to be changed in the sample to support a dynamic service.
0 Kudos
NigelDsouza
Frequent Contributor
When you are working with this sample there 3 changes necessary to make in order to make it work when you embed it in your application.
1. Change the URLS =  Which you have already done.

2. you have to set the parameter layers through an Array. You have to specify which layer/layers of the map service you are accessing  so change or alter this line
"params.setLayers(new int[]{0});" in the curly braces change specify the layer/layer the tool has to access. for ed params.setLayers(new int[]{0,1,2,3});

3. after accessing the layer you have to tell the tool on what bases or record it has to pull out. Usually it has to be a primary key like  record_id or a object id so chanege the field name in the following code according to a primary key in your mapservice.
in my case : if(curResult.getAttributes().containsKey("RECORDID")){  
    outputVal = curResult.getAttributes().get("RECORDID").toString();
With these three things done your code and tool should work fine.

do reply as whether this worked.
Regards,
Nigel.
0 Kudos
zijianzhu
Deactivated User
When you are working with this sample there 3 changes necessary to make in order to make it work when you embed it in your application.
1. Change the URLS =  Which you have already done.

2. you have to set the parameter layers through an Array. You have to specify which layer/layers of the map service you are accessing  so change or alter this line
"params.setLayers(new int[]{0});" in the curly braces change specify the layer/layer the tool has to access. for ed params.setLayers(new int[]{0,1,2,3});

3. after accessing the layer you have to tell the tool on what bases or record it has to pull out. Usually it has to be a primary key like  record_id or a object id so chanege the field name in the following code according to a primary key in your mapservice.
in my case : if(curResult.getAttributes().containsKey("RECORDID")){  
    outputVal = curResult.getAttributes().get("RECORDID").toString();
With these three things done your code and tool should work fine.

do reply as whether this worked.
Regards,
Nigel.


Hello,

  I m currently using the new ArcSDK 10.2.3. The problem is that I can not change the layer to identify. Whaterver I put, it will do the identify tasks in all the layers. Does the function setLayer function not any more?
0 Kudos
LuisDuarte
New Contributor
Buen dia
Tengo problemas al reproducir el ejemplo del IdentifiTask
al hacer onclick sobre la pantalla no me muestra ninguna propiedad del mapa
la línea
mResult = mIdentifyTask.execute(mParams);

me devuelve mResult = null

pienso que debe ser por las escalas del dibujo, yo genero el archivo shape con ARCMAP pero no consigo que mis propiedades se puedan visualizar

Gracias,
0 Kudos
RobertBurke
Esri Contributor
Luis Bienvenido al Forum!
es el "archivo shape" = Esri 'shapefile'?
¿Está utilizando el SDK de Android?
aqui?:
https://developers.arcgis.com/android/sample-code/identify-task/

Gracias
0 Kudos
LuisDuarte
New Contributor
Buen dia
Gracias por contester si yo utilizo el SDK
pero tengo la duda, para poder utilizar mapas propios es necesario de un MapServer?
0 Kudos