Select to view content in your preferred language

find lattiude and longitude

887
5
07-30-2012 03:52 AM
popmotsy
Emerging Contributor
hi,

I want latitude and longitude  in degrees for the geometry points.

for ex :
private function gHandler(e:GeometryServiceEvent):void
{
var ge:Geometry = (event.result as Array)[0];
        const pt:MapPoint = ge as MapPoint

now i am using webMercatorToGeographic here but lat, long not comes in degrees..

Any help..!!
Tags (2)
0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus
Pop Motsy,

   It is degrees but it is decimal degrees. I suppose you want degrees minutes and seconds then.
   For that you have to do a little math and string manipulation.

            private function deg_to_dms ( degfloat:Number ):String
            {
                //Input must be non-negative:
                if (degfloat < 0)
                    return "error";
                
                //Compute degrees, minutes and seconds:
                var deg:int = int(degfloat);
                var minfloat:Number = 60 * ( degfloat - deg );
                var min:int = int( minfloat );
                var secfloat:Number = 60 * ( minfloat - min );
                
                var rString:String = "";
                rString = deg + "º" + min + "'" + secfloat.toFixed(4) + "''";
                return rString;
            }


Don't forget to click the Mark as answer check on this post and to click the top arrow (promote).
Follow the steps as shown in the below graphic:
0 Kudos
popmotsy
Emerging Contributor
Ok fine..

But i want in decimal degrees...
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Pop Motsy,

   Hmm... You get the mappoint back in decimal degrees when you use webMercatorToGeographic if your geometry is in webmercator to begin with....
0 Kudos
popmotsy
Emerging Contributor
Hi,

Yes... i got my mappoint back like  x:39.29 y:26.28

but i want  lat:39.0823  long: -75.3424 .

so is there any solution for that...
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Pop Motsy,

   So what is the WKID or spatial reference of your geometry before you attempt to use webMercatorToGeographic? As the name of function indicates it is only intended to handle webMercator data.
0 Kudos