hello , How Can I hide an object of type ArcGISDynamicMapServiceLayer ?? I

3609
22
11-14-2014 09:13 AM
LourdesOlvera
New Contributor

hello , How Can I hide an object of type ArcGISDynamicMapServiceLayer ??

I used : dynamicLayer.setVisible(false);  but does not work.

this is my code:

public void solar(View button){

  String dynamicMapURL = "http://iner.energia.gob.mx:6080/arcgis/restp/services/INER/SOLAR_GLOBAL/MapServer";

  ArcGISDynamicMapServiceLayer dynamicLayer = new ArcGISDynamicMapServiceLayer(

  dynamicMapURL);

  dynamicLayer.setVisible(true);

  if(geocap.getVisibility()==View.GONE){

  geocap.removeAllViews();

      geocap.setVisibility(View.VISIBLE);

      solar();

  }else{

  geocap.setVisibility(View.GONE);

  dynamicLayer.setVisible(false);

  }

  }

0 Kudos
22 Replies
LourdesOlvera
New Contributor

hello, thank you very much for attending my questions, and I could fix the maps look in the API and gave me the solution. Now I have another problem, I'm making a "AsyncTask" to bring a query, but when running my program gives me this error:

12-06 10:36:50.937: E/AndroidRuntime(11225): FATAL EXCEPTION: AsyncTask #5

12-06 10:36:50.937: E/AndroidRuntime(11225): java.lang.RuntimeException: An error occured while executing doInBackground()

12-06 10:36:50.937: E/AndroidRuntime(11225): at android.os.AsyncTask$3.done(AsyncTask.java:299)

12-06 10:36:50.937: E/AndroidRuntime(11225): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)

12-06 10:36:50.937: E/AndroidRuntime(11225): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)

12-06 10:36:50.937: E/AndroidRuntime(11225): at java.util.concurrent.FutureTask.run(FutureTask.java:239)

12-06 10:36:50.937: E/AndroidRuntime(11225): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)

12-06 10:36:50.937: E/AndroidRuntime(11225): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)

12-06 10:36:50.937: E/AndroidRuntime(11225): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)

12-06 10:36:50.937: E/AndroidRuntime(11225): at java.lang.Thread.run(Thread.java:841)

12-06 10:36:50.937: E/AndroidRuntime(11225): Caused by: java.lang.NoClassDefFoundError: com.esri.core.tasks.ags.query.Query

12-06 10:36:50.937: E/AndroidRuntime(11225): at com.example.tablaanalisis.MainActivity$QueryTable.doInBackground(MainActivity.java:214)

12-06 10:36:50.937: E/AndroidRuntime(11225): at com.example.tablaanalisis.MainActivity$QueryTable.doInBackground(MainActivity.java:1)

12-06 10:36:50.937: E/AndroidRuntime(11225): at android.os.AsyncTask$2.call(AsyncTask.java:287)

12-06 10:36:50.937: E/AndroidRuntime(11225): at java.util.concurrent.FutureTask.run(FutureTask.java:234)

12-06 10:36:50.937: E/AndroidRuntime(11225): ... 4 more

In my project I have imported "ArcGIS for Android 10.2.3" with all its libraries ... That I can do?

0 Kudos
MengyiGuo
Occasional Contributor

I found this error:

Caused by: java.lang.NoClassDefFoundError: com.esri.core.tasks.ags.query.Query

I would suggest try com.esri.core.tasks.ags.query.Query instead of Query in your definition.

0 Kudos
LourdesOlvera
New Contributor

THIS IS MY CODE :

public void consultar (View button) {

  dato1=sp_Entidad_Estatal.getSelectedItem().toString();

  dato2=sp_Tipo_Energia.getSelectedItem().toString();

  if ("Jalisco".equals(dato1) && "Eólica".equals(dato2)) {

             String[ ] parametros = {servidor_URL , "ESTADO='"+dato1+"' AND ENERGIA='"+dato2+"'"};

                                //String [] queyParms = {[0],[1]} [url],[consulta]

      

             // QueryTable objeto = new QueryTable();

            //objeto.execute(parametros);   

            

         new  QueryTable().execute(parametros); 

        

  } else {

  

  Toast toast2 = Toast.makeText(MainActivity.this, "NO SON LOS DATOS" , Toast.LENGTH_LONG);

              toast2.show();

  

  } // fin else 

  

  } //fin de metodo consultar

 

  private class QueryTable extends AsyncTask <String, Void, FeatureSet> {

  int caso ;

                     

         @Override                   //Resultado

         protected FeatureSet doInBackground (String... parametros) {

        

        if (parametros == null || parametros.length <= 1)

      return null;

        

         String url = parametros[0];          // esto es targetServerURL

         String whereClause = parametros[1];

     

                 if (url == servidor_URL) {

                

                 Toast toast2 = Toast.makeText(MainActivity.this, "HAY DATOS" , Toast.LENGTH_LONG);

                   toast2.show();

                 

         } else {

        

        Toast toast2 = Toast.makeText(MainActivity.this, "NO HAY DATOS" , Toast.LENGTH_LONG);

                    toast2.show();

         }

        

         Query query = new Query();

        SpatialReference sr = SpatialReference.create(102100);

        query.setOutSpatialReference(sr);

        query.setReturnGeometry(true);

        String[] outfields = new String[] { "*" };

        query.setOutFields(outfields);

        query.setWhere(whereClause);

        QueryTask qTask = new QueryTask(url);

        FeatureSet fs = null;

        try {

        fs = qTask.execute(query);

        } catch (Exception e) {

        System.out.println(e.getMessage());

        }

        return fs;

        

         }//fin de doInBackground

        

         

         protected void onPostExecute(FeatureSet resultado) {

        

        if (resultado != null) {

    

     Graphic [] grs = resultado.getGraphics();

    

     if (grs.length > 0) {

    

     System.out.println(resultado);

    

    // String poi_name = (String) gr.getAttributeValue("NAME");

            

     } // fin de if (grs.length > 0)

    

    

     } // fin if (resultado != null)

        

         } //fin de onPostExecut

                                          

  } // fin de AsyncTask 

} // fin de MainActivity

--> It is a test of any query ,

0 Kudos
MengyiGuo
Occasional Contributor

Query query = new Query();

change it  to

com.esri.core.tasks.ags.query.Query query = new Query();

LourdesOlvera
New Contributor

Hi , I try this :

com.esri.core.tasks.ags.query.Query qParameters = new Query();

com.esri.core.tasks.ags.query.QueryTask qTask = new QueryTask(url);

com.esri.core.map.FeatureSet resultado = qTask.execute(qParameters);

because this classes caused error in the code . this is the result :

12-09 12:53:03.728: D/libEGL(29724): loaded /vendor/lib/egl/libEGL_adreno.so

12-09 12:53:03.728: D/libEGL(29724): loaded /vendor/lib/egl/libGLESv1_CM_adreno.so

12-09 12:53:03.748: D/libEGL(29724): loaded /vendor/lib/egl/libGLESv2_adreno.so

12-09 12:53:03.748: I/Adreno-EGL(29724): <qeglDrvAPI_eglInitialize:316>: EGL 1.4 QUALCOMM build:  (CL4169980)

12-09 12:53:03.748: I/Adreno-EGL(29724): OpenGL ES Shader Compiler Version:17.01.10.SPL

12-09 12:53:03.748: I/Adreno-EGL(29724): Build Date: 12/01/13 Sun

12-09 12:53:03.748: I/Adreno-EGL(29724): Local Branch:

12-09 12:53:03.748: I/Adreno-EGL(29724): Remote Branch:

12-09 12:53:03.748: I/Adreno-EGL(29724): Local Patches:

12-09 12:53:03.748: I/Adreno-EGL(29724): Reconstruct Branch:

12-09 12:53:03.818: D/OpenGLRenderer(29724): Enabling debug mode 0

12-09 12:53:15.329: W/dalvikvm(29724): VFY: unable to find class referenced in signature (Lcom/esri/core/map/FeatureSet;)

12-09 12:53:15.329: E/dalvikvm(29724): Could not find class 'com.esri.core.tasks.ags.query.Query', referenced from method com.example.tablaanalisis.MainActivity$AsyncQueryTask.doInBackground

12-09 12:53:15.329: W/dalvikvm(29724): VFY: unable to resolve new-instance 1143 (Lcom/esri/core/tasks/ags/query/Query;) in Lcom/example/tablaanalisis/MainActivity$AsyncQueryTask;

12-09 12:53:15.329: D/dalvikvm(29724): VFY: replacing opcode 0x22 at 0x000b

12-09 12:53:15.329: W/dalvikvm(29724): VFY: unable to find class referenced in signature (Lcom/esri/core/map/FeatureSet;)

12-09 12:53:15.329: W/dalvikvm(29724): VFY: unable to find class referenced in signature (Lcom/esri/core/map/FeatureSet;)

12-09 12:53:15.329: I/dalvikvm(29724): Could not find method com.esri.core.map.FeatureSet.getGraphics, referenced from method com.example.tablaanalisis.MainActivity$AsyncQueryTask.onPostExecute

12-09 12:53:15.329: W/dalvikvm(29724): VFY: unable to resolve virtual method 9278: Lcom/esri/core/map/FeatureSet;.getGraphics ()[Lcom/esri/core/map/Graphic;

12-09 12:53:15.329: D/dalvikvm(29724): VFY: replacing opcode 0x6e at 0x0002

12-09 12:53:15.329: E/dalvikvm(29724): Could not find class  'com.esri.core.map.FeatureSet', referenced from method com.example.tablaanalisis.MainActivity$AsyncQueryTask.onPostExecute

12-09 12:53:15.329: W/dalvikvm(29724): VFY: unable to resolve check-cast 1142 (Lcom/esri/core/map/FeatureSet;) in Lcom/example/tablaanalisis/MainActivity$AsyncQueryTask;

12-09 12:53:15.329: D/dalvikvm(29724): VFY: replacing opcode 0x1f at 0x0000

12-09 12:53:15.329: D/dalvikvm(29724): DexOpt: unable to opt direct call 0x243f at 0x0d in Lcom/example/tablaanalisis/MainActivity$AsyncQueryTask;.doInBackground

12-09 12:53:15.329: D/dalvikvm(29724): DexOpt: unable to opt direct call 0x2444 at 0x2d in Lcom/example/tablaanalisis/MainActivity$AsyncQueryTask;.doInBackground

12-09 12:53:15.329: W/dalvikvm(29724): threadid=15: thread exiting with uncaught exception (group=0x415668b0)

12-09 12:53:15.339: E/AndroidRuntime(29724): FATAL EXCEPTION: AsyncTask #5

12-09 12:53:15.339: E/AndroidRuntime(29724): java.lang.RuntimeException: An error occured while executing doInBackground()

12-09 12:53:15.339: E/AndroidRuntime(29724): at android.os.AsyncTask$3.done(AsyncTask.java:299)

12-09 12:53:15.339: E/AndroidRuntime(29724): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)

12-09 12:53:15.339: E/AndroidRuntime(29724): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)

12-09 12:53:15.339: E/AndroidRuntime(29724): at java.util.concurrent.FutureTask.run(FutureTask.java:239)

12-09 12:53:15.339: E/AndroidRuntime(29724): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)

12-09 12:53:15.339: E/AndroidRuntime(29724): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)

12-09 12:53:15.339: E/AndroidRuntime(29724): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)

12-09 12:53:15.339: E/AndroidRuntime(29724): at java.lang.Thread.run(Thread.java:841)

12-09 12:53:15.339: E/AndroidRuntime(29724): Caused by: java.lang.NoClassDefFoundError: com.esri.core.tasks.ags.query.Query 12-09

12:53:15.339: E/AndroidRuntime(29724): at com.example.tablaanalisis.MainActivity$AsyncQueryTask.doInBackground(MainActivity.java:111) 12-09 12:53:15.339: E/AndroidRuntime(29724): at com.example.tablaanalisis.MainActivity$AsyncQueryTask.doInBackground(MainActivity.java:1)

12-09 12:53:15.339: E/AndroidRuntime(29724): at android.os.AsyncTask$2.call(AsyncTask.java:287)

12-09 12:53:15.339: E/AndroidRuntime(29724): at java.util.concurrent.FutureTask.run(FutureTask.java:234)

12-09 12:53:15.339: E/AndroidRuntime(29724): ... 4 more

please help me , I do not know what is wrong ...

0 Kudos
MengyiGuo
Occasional Contributor

12-09 12:53:15.329: E/dalvikvm(29724): Could not find class 'com.esri.core.tasks.ags.query.Query', referenced from method com.example.tablaanalisis.MainActivity$AsyncQueryTask.doInBackground

May I verify the ArcGIS Runtime SDK version?

0 Kudos
LourdesOlvera
New Contributor

is ArcGis for Android 10.2.3

use the same SDK and the same method for other queries.

0 Kudos
MengyiGuo
Occasional Contributor

com.esri.core.tasks.ags.query.QueryTask is deprecated in 10.2.4 and the replacement should be com.esri.core.tasks.query.QueryTask.

QueryTask | ArcGIS Android 10.2.4 API

QueryTask | ArcGIS Android 10.2.4 API

Notice that execute method asks for a different parameter in the two class. It should work if you are using ArcGIS Runtime SDK 10.2.3 but maybe not 10.2.4. I'm not sure if the issue is caused by this but I see the error message:

"Caused by: java.lang.NoClassDefFoundError: com.esri.core.tasks.ags.query.Query 12-09"

Maybe try QueryParameters instead of Query, and use queryTask.execute(QueryParameters) method for query.

And double check your query parameters since you mentioned the same code works.

// Define a new query and set parameters

QueryParameters mParams = new QueryParameters();

mParams.setWhere(whereClause);

mParams.setReturnGeometry(true); 

// Define the new instance of QueryTask

QueryTask queryTask = new QueryTask(mFeatureServiceURL);

FeatureResult results; 

try {

// run the querytask

results = queryTask.execute(mParams);

return results;

} catch (Exception e)

{ e.printStackTrace(); } return null;

0 Kudos
LourdesOlvera
New Contributor

you suggest to change to 10.2.4 and classes remain this way:

- com.esri.core.tasks.query.QueryTask

- com.esri.core.tasks.query.QueryParameters

- com.esri.core.map.FeatureSet

These classes I saw on "Android 10.2.4 ArcGIS API".

Indeed queryQuery was replaced in 10.2.4 by QueryTask

0 Kudos
LourdesOlvera
New Contributor

not work .... now change to 10.2.4 and wrote the classes as referenced in the API ...

com.esri.core.tasks.query.QueryParameters qParameters = new com.esri.core.tasks.query.QueryParameters ();

com.esri.core.tasks.query.QueryTask qTask = new com.esri.core.tasks.query.QueryTask(url);

com.esri.core.map.FeatureResult resultado com.esri.core.map.FeatureResult ();

the result :

12-09 18:15:48.831: E/dalvikvm(27117): Could not find class 'com.esri.core.tasks.query.QueryParameters', referenced from method com.example.tablaanalisis.MainActivity$AsyncQueryTask.doInBackground

:::::::::::::::::::::::

12-09 18:15:48.831: E/dalvikvm(27117): Could not find class 'com.esri.core.map.FeatureResult', referenced from method com.example.tablaanalisis.MainActivity$AsyncQueryTask.onPostExecute

::::::::::::::::::::::::::::..

12-09 18:15:48.841: E/AndroidRuntime(27117): Caused by: java.lang.NoClassDefFoundError: com.esri.core.tasks.query.QueryParameters

0 Kudos