Select to view content in your preferred language

Map Extent Center

893
1
10-18-2011 05:59 PM
ShaunWeston
Frequent Contributor
I have built a geoprocessing service and one of the inputs to the service is the centre point of the map (which is ArcGIS Viewer for Flex 2.4).

You can get the centre point easy enough from the application using:
map.extent.center.x and map.extent.center.y, however I'm not quite sure how to send these to the geoprocessing service automatically when a button is clicked on a widget. Maybe there is an easy solution and I'm not thinking of it?

I could use the geoprocessing widget and make the default value for the input map.extent.center.x and map.extent.center.y, however I can't seem to do that either. How can you add that code into an xml file?

e.g.

        <param name="Drive_Times"
               defaultvalue="{map.extent.center.x}"
               label="Drive times"
               required="false"
               type="string"
               visible="true"/>
Tags (2)
0 Kudos
1 Reply
Juan_CarlosFranco
Esri Contributor
It�??s not possible to do this via the configuration file. One way to make this work is to prepare the center map point input, get the GP input parameter and update it before the request object is created and sent (before the runGPIfRequiredParamsComplete function):

//assuming the input format is: x,y
var centerMapPointInput:String = map.extent.center.x + ',' + map.extent.center.y; 
var driveTimesParam:StringParameter = gpParamHandler.findInputParamByName("Drive_Times") as StringParameter;
driveTimesParam.defaultValue = centerMapPointInput;


The parameter would also need to be hidden (in the config) to avoid overriding the center point input.

<param name="Drive_Times"
label="Drive times"
required="false"
type="string"
visible="false"/>
0 Kudos