Can you use a featureserver as a map layer in the Runtime SDK for Java?

4232
3
Jump to solution
04-13-2015 10:30 AM
TedJacobi
New Contributor

I have a FeatureServer already made and on the REST server (I think that is correct terminology), I want to use the FeatureServer in a map application. It consists of multiple trails that I want to display on a basemap. I made the simple map from the online tutorial but I am not sure how or if I can add my FeatureServer layer.

Would it be easier to use a map made on ArcGIS Online that uses the FeatureServer?

I also have a MapServer that I could use instead.

What would work the best and how would I go about doing it?

Thanks!

0 Kudos
1 Solution

Accepted Solutions
FreddieGibson
Occasional Contributor III

You can use a FeatureService or MapService as a layer in Runtime Java. For the FeatureService you'll want to take a look at the following sample.

https://developers.arcgis.com/java/sample-code/feature-layer/

The code you're looking for will resemble the following:

ArcGISFeatureLayer featureLayer = new ArcGISFeatureLayer(FEATURE_SERVICE_URL);

featureLayer.setName("Feature Layer (San Francisco incidents)");

map.getLayers().add(featureLayer);

For the Map Service you'll want to look at the following sample.

https://developers.arcgis.com/java/sample-code/map-layer-ordering/

The code you're looking for will resemble the following:

ArcGISDynamicMapServiceLayer dynamicLayer = new ArcGISDynamicMapServiceLayer(MAP_SERVICE_URL);

dynamicLayer.setName("Dynamic Layer (Unemployment Rate)");

map.getLayers().add(dynamicLayer);

View solution in original post

3 Replies
FreddieGibson
Occasional Contributor III

You can use a FeatureService or MapService as a layer in Runtime Java. For the FeatureService you'll want to take a look at the following sample.

https://developers.arcgis.com/java/sample-code/feature-layer/

The code you're looking for will resemble the following:

ArcGISFeatureLayer featureLayer = new ArcGISFeatureLayer(FEATURE_SERVICE_URL);

featureLayer.setName("Feature Layer (San Francisco incidents)");

map.getLayers().add(featureLayer);

For the Map Service you'll want to look at the following sample.

https://developers.arcgis.com/java/sample-code/map-layer-ordering/

The code you're looking for will resemble the following:

ArcGISDynamicMapServiceLayer dynamicLayer = new ArcGISDynamicMapServiceLayer(MAP_SERVICE_URL);

dynamicLayer.setName("Dynamic Layer (Unemployment Rate)");

map.getLayers().add(dynamicLayer);

TedJacobi
New Contributor

Thanks I had found that once but for some reason couldn't again.

Another related question for the FeatureServer, if I have multiple features in the featureserver do I need to add a url for each one assigning it to a variable and then with the method:

      private void createGeodatabaseFeatureServiceTable()

     {

          featureServiceTable = new GeodatabaseFeatureServiceTable( FEATURE_SERVICE_URL, 0);

     }

Add a new featureServiceTable for each URL variable and id number?

0 Kudos
EricBader
Occasional Contributor III

Ted,

One FeatureService URL can have multiple layer ids. Or, it can have just one.

Does this help?