AnsweredAssumed Answered

Problem When Show MapServer url On Android Implementation

Question asked by velyshredder on Sep 8, 2015
Latest reply on Sep 9, 2015 by WCrick-esristaff

Hello everyone, I am new on Arcgis map. So my question is basic but i get some problem.

 

I am trying this sample application, this is my code :

 

-------------------------------------------------------------------------------------------------

 

 

package wilmar.helloworldarcgis;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.esri.android.map.FeatureLayer;
import com.esri.android.map.MapView;
import com.esri.core.geodatabase.GeodatabaseFeatureServiceTable;
import com.esri.core.geodatabase.GeodatabaseFeatureServiceTable.Status;
import com.esri.core.map.CallbackListener;
import com.esri.core.renderer.ClassBreaksRenderer;

public class MainActivity extends Activity {

 

  MapView mMapView;
   GeodatabaseFeatureServiceTable table;
   FeatureLayer feature_layer;
   ClassBreaksRenderer wind_renderer;
  static int LAYER_ID = 0;
   View calloutView;

   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {

 

   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);

   mMapView = (MapView) findViewById(R.id.map);
   mMapView.setEsriLogoVisible(true);
   mMapView.enableWrapAround(true);

   // Inflate the view for the callouts
   calloutView = View.inflate(this, R.xml.callout, null);

   String url = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer";

   // Create the GeodatabaseFeatureServiceTable from service url and layer
  // id
   table = new GeodatabaseFeatureServiceTable(url, LAYER_ID);

   // Initializing the GeodatabaseFeatureServiceTable asynchronously
   table.initialize(new CallbackListener<GeodatabaseFeatureServiceTable.Status>() {

 

   @Override
   public void onCallback(Status objs) {

   if (objs == Status.INITIALIZED) {

 

   // Creating a feature table
   feature_layer = new FeatureLayer(table);
   // Adding feature layer to the map
   mMapView.addLayer(feature_layer);
   }

  }

 

   @Override
   public void onError(Throwable e) {

   // Get the error using getInitializationError() method
   Toast.makeText(getApplicationContext(), "Feature Layer not available", Toast.LENGTH_LONG).show();
   }

  });
   }


  /*
  * Called when the activity is destroyed
  */

   @Override
   protected void onDestroy() {

   super.onDestroy();

   }

 

   /*
  * Called when the activity pauses
  */

   @Override
   protected void onPause() {

 

   super.onPause();
   mMapView.pause();

   }

 

   /*
  * Called when the activity resumes
  */

   @Override
   protected void onResume() {

 

   super.onResume();
   mMapView.unpause();

   }

 

}

-------------------------------------------------------------------------------------------------

On layout xml i put just some map.

I run this code and i got the result is :

 

When i using this url : http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer

It just show basic map, without layer on map.

 

But when i use this url : http://tmservices1.esri.com/arcgis/rest/services/LiveFeeds/NOAA_METAR_current_wind_speed_direction/MapServer

It show layer on map. (Like arrow pointer)

 

 

My question is....

did i wrong on my code..?

if i wrong can you suggest something so the map will show the layer using first url.

and

I relize something, the first url is Geometry Type: esriGeometryPolyline

 

and the second is Geometry Type: esriGeometryPoint

 

Is there have different way if i want to implement it on map..?

 

 

Thanks For Your help.

Outcomes