Select to view content in your preferred language

ListMapServices and ExportToPDF - how to pull in external layers

2438
3
03-02-2012 04:39 AM
KevinGooss
Regular Contributor
I am trying to use python and arcpy.mapping to export a map to pdf. I want the map to have some layers from my mxd and i also want to pass in a url to an external layer (like, say, esri streets) from a different server.
I can turn layers on and off in my own mxd and zoom to an aoi and all that jazz and then export to pdf and it works.
But how can i integrate a layer from an external source like another arcgis server?

I see the ListMapService method but i have never been successful in getting it to run. I always get a connection error. Why are there 2 required parameters to this method - url and server? Seems to me that if you have the url to a rest services directory then you have everything you need to list out the services available - that's all my browser needs.

I also see that i can add any .lyr file to my mxd before i export it. But I want to add layers that i don't own and that are not on my server.
Can this be done at 10.0?
Tags (2)
0 Kudos
3 Replies
JeffBarrette
Esri Regular Contributor
You must author a layer file that points to that other service.  You can add that layer file to your MXD using the arcpy.mapping AddLayer function.

Jeff
0 Kudos
KevinGooss
Regular Contributor
Hummm.. Somewhat of a limitation. What if my app allows users to dynamically pull in map services that are hosted by others and then i want to have those in a print product?
Seems like a url should be all that is required to generate a layer whether it is in the browser or server side in python code.
As long as my server can resolve the url that the browser resolves then i should be able to expose these layers in print without having to have them in my mxd/msd.
0 Kudos
AndrewChapkowski
Esri Regular Contributor
You can leverage the map service's ability to create layer files to view the service in ArcMap.  For example: http://server.arcgisonline.com/ArcGIS/rest/services/CSP_Imagery_World_2D/MapServer?f=lyr&v=9.3
This will allow you to download a layer file (.lyr) to disk.  From there, you can then add the map service layer file to your MXD.
0 Kudos