I find example to set map extent that works ok in ArcMap via ..

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
newExtent = df.extent
newExtent.XMin, newExtent.YMin = newExtent.XMin+100, newExtent.YMin
newExtent.XMax, newExtent.YMax = newExtent.XMax+1000.0, newExtent.YMax
df.extent = newExtent

I would like to publish this type of tool to make it generic geoprocessing tool for WebApp Builder- it should take the given web map service and set extent of map in the web session.

It is not clear to me - whether this is possible at all? How to get web map object with python set its extent ? If I change the extend of mxd document like to code above, I have impression that all users of the service will get the changed extend, that this is not limited to that particualr web session. In Java script API there is an object Map to manipulate web map, does something like this exist in Python?

I would like to pass map service name as parameter

can pass this as a tool parameter). Is this possible at all?

1 Answer 1


I'm having trouble understanding your workflow - regardless, any workflow I could imagine you're trying to achieve does not need a GP Service. I'd actually recommend against it. A gp service is the wrong tool for the job here.

First, the GP Service can't control the map you see inside a webapp. It works on its own data. (Ok yes, the data the gp service is referencing could be the same data the map service uses --but they are 2 independent services.) The only thing the GP service could do is calculate some sort of extent, and then you'd have to use javascript to make a request to the map service asking for a new extent.

If the above is what you're trying to do: have the gp service change the extent/view of the map service.... just do this in javascript. All the items are available in the API to modify the map view.

If this isn't your desired goal... you'll have to explain further. I dont understand the "pass a map service name as a parameter". If you want some sort of "start" page where you just put in "MapServiceA" and it opens a new map window, well again, that should be all JavaScript. No need for a GP Service.

  • The reason why I want to use GP is because I can make it availabel for user of WebApp Builder Portal Edition (additional Javascript widget can only be included via Developer edition and process which is too heavy for normal users).
    – DVored
    Commented Oct 19, 2015 at 10:56
  • This is otherwise Goto XY widget required by user on Web App Builder Portal for most of web apps they are going to build (the formula in the example is not the final one, just the one to check technics, that's why it looks a bizarre goal)
    – DVored
    Commented Oct 19, 2015 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.