Valid map extent

275
3
04-20-2012 08:14 AM
LuisGarcia2
Occasional Contributor II
I am trying to have my clients see the extent of a graphics layer added dynamically. What I do is set map.Extent = myGraphicsLayer.FullExtent. That works fine; but there is a caveat. The client normally is given a set of data columns to choose from the geographic coordinates that are all double digit data types. Among those columns will be the Latitude and Longitude. Normally it is pretty obvious what the lat and long columns are; but they may choose something else. If they do choose something else then there may/may not be points displayed. That is fine. Now, when the line to to set the map in the extent of the graphics layer executes, then the map completely freezes. I looked into it and it seems that the extent is not right; it may be coming up with numbers that are completely off. So, my question is, how can I know when I have a valid extent after adding my data to the graphics layer?
I know that the first question that I may get back is "why are we offering our clients all those columns in the first place?" And the reason is very simple, the names are not fixed, we read the columns from different databases, and our application requires that we let the client select the columns; we do narrow them to double digits data type only though.
Thanks!
0 Kudos
3 Replies
DeminHu
New Contributor
I think if the client select a differnt  coordinate system other than your map, probably you should use GeometryService to project , then add the projected  env on the map.
0 Kudos
JenniferNery
Esri Regular Contributor
Demin is right. Here's an SDK sample that does that: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Project. How are you getting your zoom extent? Do you union the selected lat/lon values? If the resulting extent is a different spatial reference from your map, you can use GeometryService.ProjectAsync() or WebMercator as in this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#AddGraphics.
0 Kudos
LuisGarcia2
Occasional Contributor II
Thanks for your replies. I am using WebMercator right now. I will take a look at the first example Jennifer mentions.
Thanks again!
0 Kudos