Select to view content in your preferred language

Flex - Display latitude and longitue

4230
12
04-02-2010 09:34 AM
JacksonTrappett
Frequent Contributor
Hello, I can't seem to search the old forums anymore so I figured I'd try asking on these new ones.

My question:
I have a flex app that is displaying a map in a projected coordinate system (WGS 1984 UTM Zone 12N) which means that my map units are in meters.  I am displaying the coordinate position of the mouse using two <mx:text> elements but of course it is displaying meters.  What my user's would like to see is a display of the latitude and longitude of the mouse while still keeping the map in the projected coordinate system.  Is this possible?
Tags (2)
0 Kudos
12 Replies
JayGeisen
Regular Contributor
Thanks Jackson.  I will give this a try.
0 Kudos
SandraPanicucci
Deactivated User
Jackson,
I've been trying to implement this in my project going to a mapclick event. I have tried following your suggestions but keep getting a -- Access of possibly undefined property SET_XY through a refernce with static type Class-- error.

Am I correct in assuming --public static const SET_XY:String = "setxyLoc"; --this line is supposed to be in the mapmanager? Any ideas on what obvious clue I'm missing?
0 Kudos
RoyceVerboom
Deactivated User
I realize this is a bit of an old post, but has anyone come across a function for State Plane projections that are in Transverse Mercator (Like Nevada, Arizona, etc)?  It seems like there are many functions out there for SP in the Conformal Conic and UTM zones (like the one above), but I haven't had any luck with the SP in TM. 

So, has anyone come across anything like that?  I tried using the above function and modifying it a bit and that did not work out for me.  I guess the SP in TM requires a little bit different math than UTM zones...

Edit:
I wanted to attach the code I was attempting to use.  I changed it up a bit to work in VB.  Also, my original XY units are in feet, so I that is why you see the Dim easting As Double = y * 0.3048006096012, to change it to meters

Function StateTMDD(ByVal x As Double, ByVal y As Double) As PointN
      Dim MapPoint As New PointN
      'The math in this function was based off of methods found on httpas'www.gpsy.com/gpsinfo/geotoutm/ by Karen Nakamura

      'Set easting and northing from the MapPoint


      Dim easting As Double = y * 0.3048006096012       'the X coordinate from the service in UTM meters
      Dim northing As Double = x * 0.3048006096012        'the Y coordinate from the service in UTM meters


      Dim avflat As Double = 298.257223563         'the Inverse Flattening that ArcGIS provides in the geographic coordinate description
      Dim semiMAJaxis As Double = 6378137.0        'the Semimajor Axis that ArcGIS provides in the geographic coordinate description
      Dim meridORIG As Double = -118.583333             'the Central Meridian that ArcGIS provides in the projection description
      Dim scFACTorig As Double = 0.9999         'the Scale Factor that ArcGIS provides in the projection description
      Dim falseNOR As Double = 400000              'the False Northing that ArcGIS provides in the projection description
      Dim falseEST As Double = 80000         'the False Easting that ArcGIS provides in the projection description
      Dim latORG As Double = 34.75            'Latitude of Origin


      'Calculations
      Dim flattening As Double = 1.0 / avflat           'change Inverse Flattening into flattening
      Dim eccentricity As Double = 0.08181905782            'calculate eccentricity         (2.0 * flattening) - (flattening * flattening)
      Dim semiMINaxis As Double = 6356752.3141403561 'calculate the Semiminor Axis       semiMAJaxis * (Math.Pow((1.0 - eccentricity), 0.5))
      Dim n As Double = (semiMAJaxis - semiMINaxis) / (semiMAJaxis + semiMINaxis)     'calculate n
      Dim semiMAJecc As Double = semiMAJaxis * (1.0 - eccentricity)                     'calculate the Semimajor Eccentricity
      Dim semiMINecc As Double = 1.0 / (Math.Sin((1.0 / 3600.0) * Math.PI / 180.0))         'calculate the Semiminor Eccentricity
      Dim epsilon As Double = 1097.0 * (Math.Pow(n, 4.0)) / 512.0                        'calculate epsilon
      Dim delta As Double = 151.0 * (Math.Pow(n, 3.0)) / 96.0 - (417.0 * (Math.Pow(n, 5.0)) / 128.0)                 'calculate delta
      Dim gamma As Double = 21.0 * (Math.Pow(n, 2.0)) / 16.0 - (55.0 * (Math.Pow(n, 4.0)) / 32.0)                    'calculate gamma
      Dim beta As Double = 3.0 * n / 2.0 - (27.0 * (Math.Pow(n, 3.0)) / 32.0) + (269.0 * (Math.Pow(n, 5.0)) / 512.0)          'calculate beta
      Dim alpha As Double = (semiMAJaxis + semiMINaxis) / 2.0 * (1.0 + (Math.Pow(n, 2.0)) / 4.0 + (Math.Pow(n, 4.0)) / 64.0)  'calculate alpha
      Dim phiprime As Double = (northing - falseNOR) / (scFACTorig * alpha)                                                   'calculate phiprime
      Dim phiF As Double = phiprime + beta * Math.Sin(2.0 * phiprime) + gamma * Math.Sin(4.0 * phiprime) + delta * Math.Sin(6.0 * phiprime) + epsilon * Math.Sin(8.0 * phiprime) 'calculate phiF
      Dim v As Double = semiMAJaxis / (Math.Pow(1.0 - (eccentricity * (Math.Pow(Math.Sin(phiF), 2.0))), 0.5))           'calculate v
      Dim p As Double = semiMAJecc / Math.Pow((1.0 - (eccentricity * Math.Pow(Math.Sin(phiF), 2.0))), 1.5)              'calculate p
      Dim VII As Double = ((Math.Tan(phiF) * Math.Pow((easting - falseEST), 2.0)) / (2.0 * Math.Pow(scFACTorig, 2.0) * v * p)) * ((1.0 / (Math.Sin((1.0 / 3600.0) * Math.PI / 180.0))))   'calculate VII
      Dim VIII As Double = ((Math.Tan(phiF) * Math.Pow((easting - falseEST), 4.0)) / (24.0 * Math.Pow(scFACTorig, 4.0) * Math.Pow(v, 3.0) * p)) * (5.0 + 3.0 * Math.Pow((Math.Tan(phiF)), 2.0)) * (1.0 / (Math.Sin((1.0 / 3600.0) * Math.PI / 180.0)))  'calculate VIII
      Dim Ten As Double = ((1.0 / Math.Cos(phiF)) * Math.Pow((easting - falseEST), 3.0) * semiMINecc) / (6.0 * Math.Pow(scFACTorig, 3.0) * Math.Pow(v, 3.0)) * ((v / p) + 2.0 * Math.Pow((Math.Tan(phiF)), 2.0))   'calculate X
      Dim IX As Double = ((1.0 / Math.Cos(phiF)) * (easting - falseEST) * semiMINecc) / (scFACTorig * v) 'calculate XI
      Dim E As Double = ((1.0 / Math.Cos(phiF)) * Math.Pow((easting - falseEST), 5.0) * semiMINecc) / (120.0 * Math.Pow(scFACTorig, 5.0) * Math.Pow(v, 5.0)) * (5.0 + 28.0 * Math.Pow((Math.Tan(phiF)), 2.0) + 24.0 * Math.Pow((Math.Tan(phiF)), 4.0))  'calculate E
      Dim phiFdegrees As Double = phiF * 180.0 / Math.PI           'change phiF from radians to degrees
      Dim DDegLat As Double = (phiFdegrees - VII / 3600.0 + VIII / 3600.0) + latORG  'calculate degrees latitude
      Dim DDegLon As Double = meridORIG + (IX - Ten + E) / 3600.0           'calculate degrees longitude

      'Set the MapPoint to the new Lat and Lon
      MapPoint.X = DDegLon
      MapPoint.Y = DDegLat

      'Return the MapPoint
      Return MapPoint
0 Kudos