Feature Layers from Map Services

Posted by Dave Bouwman on January 27, 2014

Here is a lesser known fact: using the ArcGIS Javascript API, you can create a FeatureLayer from any vector layer in a MapService. Of course it will be read-only, but you still have all the usual control over it in terms of styling and interaction. If that works for you, it’s really simple: just drop the full url to the layer in the map, into the FeatureLayer constructor, and you’re up an running.

Of course you should be careful with this technique. Many times MapServices are used to display very dense data, so you may end up pulling a lot of data over the wire. But, if you happen to need more interactivity from a layer that’s already published as a MapService, this is a great way to avoid having to publish a FeatureService.

Here is a JSBin with the example running.

MapService Layer as FeatureLayer{.jsbin-embed}