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/MapSe...";
// 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/MapSe...
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/M...
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.
One thing to keep in mind is that when creating a geodatabase feature service table from a MapService, you need to use the URL to a layer in the map service (append /0 onto your url for layer 0, /1 for layer 1 etc...). The top level URL you are using is just for exporting map images which are generated on the server, geodatabase feature service tables request features from the service as json then render them on the client. To achieve this, the api requires access to a single layer in the map service with which we can query features.
Also, you need to check the features that are in the layer and the layers scale thresholds defined for each layer, it might be that there are no features in the extent you are viewing, or that the layer is turned off at that specific scale. You can check these things by performing direct queries using the rest api html pages.
Will