Zoom to wrong point

714
5
01-24-2014 11:17 AM
fuliaoli
New Contributor III
I have a form for users to enter latitude/longtitude and when sumitted, the map would centerAndZoom to the point, but the result is not what I thought would be.
Here're steps I take:
Create a point with lon/lat which, in turn, is converted to a point of webmercator using the following
point = webMercatorUtils.geographicToWebMercator(point) before setting it to a query.geometry.
Somehow, the location of point is calcualted way off.  Then I tried to create an extent around the point of webmercator, and it didn't work either.
Please help.
Thanks.
0 Kudos
5 Replies
BjornSvensson
Esri Regular Contributor
Hi fuliao li,
Could you give an example of the input lat/long values?
And the values of the webmercator point?
And the calculated extent?
0 Kudos
fuliaoli
New Contributor III
Thanks for quick response. It behaves so strange.
1)if input is  46.24850307325321 -93.98920959565058 (lat/lon)(x:-10462830.952249908 y: 5820261.834192247), I can find the point.
2)if input is 46 14 55  -93 59 21(degree, minute, second lat/lon) after conversion (x:-10462826.173417277 y:5820279.2256252095), not found, but if I add/minus 20 to the point in webmercator to create an extent, it is found. Adding less than 20, cannot find. I thought, even adding plus/minus 1 would cover the point.
3)Requiring users to put in exact decimal is not practical, I'd like to take, say 46 -93 (lat/lon) and zoom to the calculated point with certain level. However, it zooms far off the intended point, quite a way in the east of it. So the query I use to show the area fails to capture the point.
Please help.
Thanks.
0 Kudos
SteveCole
Frequent Contributor
You don't have to change how your users enter the lat/long information. Just have your users enter the lat/long as DMS and then before creating a JS API location point, convert the DMS to decimal degrees using a method such as this.

EDIT: Whoops. I now see that you say that your users can't offer this level of precision. That's going to be a problem because it's that precision that provides the true (or "better") accuracy of the point's location.
0 Kudos
fuliaoli
New Contributor III
You don't have to change how your users enter the lat/long information. Just have your users enter the lat/long as DMS and then before creating a JS API location point, convert the DMS to decimal degrees using a method such as this.

EDIT: Whoops. I now see that you say that your users can't offer this level of precision. That's going to be a problem because it's that precision that provides the true (or "better") accuracy of the point's location.


Thanks. My users want to enter decimal or degree at their choice. Of course, the simplest they would enter, say, 46, 93 I treat it as decimal. As for dms, I did this:
        lat = parseFloat(latlon[0]) + parseFloat(latlon[1])/60.0 + parseFloat(latlon[2])/3600.0
lon = -(parseFloat(latlon[3]) + parseFloat(latlon[4])/60.0 + parseFloat(latlon[5])/3600.0) ;

I'm new in GIS field. Not sure what's going on.
0 Kudos
fuliaoli
New Contributor III
Could anyone shed some light on this issue?
Thanks.
li
0 Kudos