Thursday, 11 June 2015

javascript - Load One Layer from ArcGIS Server MapServer


I am pretty new to ArcGIS Server and am building a map applications using the Javascript API. I can easily load the map layer below by adding it as a ArcGISDynamicMapServiceLayer


http://www.parkcounty.org/ArcGIS/rest/services/Roads_Map/MapServer/


As you can see there are many layers as part of the above url. What if I just want to load the roads layer as a ArcGISDynamicMapServiceLayer? I've tried replacing the above url with the road specific URL below and that does not seem to work


http://www.parkcounty.org/ArcGIS/rest/services/Roads_Map/MapServer//2


Is there something else I can do as the front end developer or is it up to those that are hosting and managing the server to create a unique url for the roads?



Answer




Make use of the layers property when asking for the exportmap operation from a dynamic map service.


REST API Help on Exportmap operation.


e.g.
This service was published with 3 visible layers. However, can make a request for certain layers.



  • show: Only the layers specified in this list will be exported.

  • hide: All layers except those specified in this list will be exported.

  • include: In addition to the layers exported by default, the layers specified in this list will be exported.

  • exclude: The layers exported by default excluding those specified in this list will be exported.




http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/export?layers=show:2



Also take a look at what additional behaviour you can do with the use of dynamic layers.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...