Turn latitude/longitude into X,Y coordinates?
I'm working on a map that will display a person's location with a dot. We have the geographical coordinates in Latitude/Longitude form. So, i'm totally lost (i'm TERRIBLE at math) as to how i can turn latitude/longitude info into X and Y coordinates so that flash can move the little dot around to the right location.
For instance: The following variables are passed into flash: Lat: 32.777654 Long: -79.933819. NOW, we need to translate that into an XY position inside the mc with the map graphic in it. I'm guessing this can be down with a mathematical conversion/equation but i have no clue how to do it. Any ideas?
Thanks for any help!
plotting LAT/LONG to X, Y, Z
So I am working on an open-source 3D Flash mapping application. You can see and download all the source code here (including the LAT/LONG data): http://code.google.com/p/meadanglobe
I found the calculations for converting LATITUDE and LONGITUDE to X, Y, Z coordinates above, yet I am just not getting accurate results! There are actually 2 issues:
1) the nodes do not appear to be in correct locations relative to each other (ie., Rome and Johannesburg are right next to each other, and San Francisco and New York City are about half way around the world from eachother!)
2) also, the nodes are not not in the right places (ie, New York City is at the South Pole!)
I assume that the second issue will be easier to solve (relative x, y, z adjustment) once the first issue is resolved -- which appears much more variant.
Anyone have any idea what is wrong here?
Here is the ActionScript that I am using:
xPos = (app.radius) * Math.cos(longitude) * Math.cos(latitude);
yPos = (app.radius) * Math.sin(longitude) * Math.cos(latitude);
zPos = (app.radius) * Math.sin(latitude);
Please help!
Turn latitude/longitude into X,Y coordinates?
I'm working on a map that will display a person's location with a dot. We have the geographical coordinates in Latitude/Longitude form. So, i'm totally lost (i'm TERRIBLE at math) as to how i can turn latitude/longitude info into X and Y coordinates so that flash can move the little dot around to the right location.
For instance: The following variables are passed into flash: Lat: 32.777654 Long: -79.933819. NOW, we need to translate that into an XY position inside the mc with the map graphic in it. I'm guessing this can be down with a mathematical conversion/equation but i have no clue how to do it. Any ideas?
you're right. i looked up the coordinates and the min/max latitude and longitude for the city map i'm using are like a bazillionth of a point apart (ie. the difference between my max & min longitude values is only .061276 of a point).
From playing with your flash file and mine, the more decimal places there are on the lat/lon values, the less accurate the star becomes. For instance, on your map, the lat/lon numbers were easy and big differences between gridlines...and i can get that star to go exactly where i want it. BUT, when i reduced all your lat/lon values down (relative to the same format on my map) the star's placement becomes very inaccurate.
So i'm guessing that since we're dealing with such a small area, that my min/max lat/lon values will have to be super accurate, right? I was hoping i could just fudge it.
Turn latitude/longitude into X,Y coordinates?
I'm working on a map that will display a person's location with a dot. We have the geographical coordinates in Latitude/Longitude form. So, i'm totally lost (i'm TERRIBLE at math) as to how i can turn latitude/longitude info into X and Y coordinates so that flash can move the little dot around to the right location.
For instance: The following variables are passed into flash: Lat: 32.777654 Long: -79.933819. NOW, we need to translate that into an XY position inside the mc with the map graphic in it. I'm guessing this can be down with a mathematical conversion/equation but i have no clue how to do it. Any ideas?
you're right. i looked up the coordinates and the min/max latitude and longitude for the city map i'm using are like a bazillionth of a point apart (ie. the difference between my max & min longitude values is only .061276 of a point).
From playing with your flash file and mine, the more decimal places there are on the lat/lon values, the less accurate the star becomes. For instance, on your map, the lat/lon numbers were easy and big differences between gridlines...and i can get that star to go exactly where i want it. BUT, when i reduced all your lat/lon values down (relative to the same format on my map) the star's placement becomes very inaccurate.
So i'm guessing that since we're dealing with such a small area, that my min/max lat/lon values will have to be super accurate, right? I was hoping i could just fudge it. shae marks