Select to view content in your preferred language

How to get the extents of the current map service (flex 1.3, agis 9.3.1)

2538
2
09-24-2010 03:08 AM
grahamcooke
Regular Contributor
In my app, the user can input the coordinates to plot a point. They can do this by right clicking the map and copying the coordinates to the clipboard and pasting into a textinput, or they can simply type them in.

I want to validate the typed in coordinates and so I created a custom validator class which extends the numeric validator and ensures that a 12 digit number is entered (6 for x and 6 for y). This works fine but I also want to ensure that the x and y entered does not go out of the bounds of the min and max exents of the currently displayed map.

I cannot work out how to get a reference to the currently displayed maps extents from my custom validator action script class. The url for the map service is dynamically passed in from .NET so is not in the config.xml. I'm sure this should be simple to do but for some reason I can't work it out. Googling around hasn't been much assistance either!

Hope someone can help!
Tags (2)
0 Kudos
2 Replies
Drew
by
Frequent Contributor
You will have to get a reference to your map component to get the extent.
The best way to do this would be to pass the map in as a parameter in your classes constructor.

Once you have the map you can then use the Extent object to see if the map point is contained within that extent...

Sample code (untested)
var isContained:Boolean = myMap.extent.contains(myMapPoint);


Hopefully that helps a little... Post some sample code if you need further assistance.

ESRI Sample project using the "contains(point:MapPoint)" method
http://resources.esri.com/help/9.3/arcgisserver/apis/flex/samples/index.html?sample=SelectPointsWith...

Drew
0 Kudos
MayJeff
Deactivated User
How do you check to make sure the XY point you entered is inside your full extent of map  instead of your current extent of map?
0 Kudos