View Full Version : degree of longitude/latitude
Macaquinho
02-15-2006, 05:01 PM
Hey folks,
I want to make a map of Europa in flash. And i want to readout the degree of longitude and latitude with the mouse cursor. The problem here, the degree lines of longitude/latitude are not linear but more like a sphere.
http://www.lib.utexas.edu/maps/europe/europe_pol_2004.jpg
my swf:
http://www.flashhilfe.de/attachment_download.php?id_attachment=306
i hope someone can help me.
Macaquinho
reyco1
02-15-2006, 05:34 PM
I cant see the swf dude
Macaquinho
02-15-2006, 07:02 PM
maybe you see it after you downloaded the swf and then open it with flash player...
Chewie
02-15-2006, 08:37 PM
there is nothing to download
Hmm, this might work...
Since the longitude lines are pretty straight, the lattitude lines could be considered concentric circles. So, lat would be the distance from the point where the long lines converge (north pole). And long would be the angle from the cursor to that point.
1) Figure out the point where the long lines converge. Don't know the pixel dimensions of your map, but let's say the point is around 470,-570. (if your map's top left corner is at 0,0)
2) Figure out degrees per pixel. For example, if the pixel dist from lat lines 40 to 60 is 580px, then deg per px = 580px/20degrees = .034 and change.
3) Lattitude would be the pixel distance from the pole (convergence point) times degPerPix.
To get Distance, use pythagorean theorem...
var yDiff = map_mc._ymouse - poleY
var xDiff = map_mc._xmouse - poleX
var pixelDistFromPole = Math.sqrt(yDiff*yDiff + xDiff*xDiff)
// multiply this by degPerPix
var degFromPole = pixelDistFromPole * degPerPix
// since the pole is 90 degrees, subtract degFromPole from 90
var lattitude = 90 - degFromPole
4) Longitude would be the angle from the pole to the cursor. To get angle, use Math.atan2(yDiff,xDiff).
so...
var long = Math.atan2(yDiff,xDiff)
This will return the angle in radians. To convert to degrees, use:
var degrees = radians/(Math.PI/180)
This is degrees relative to 0 being due East (on screen, not on map). So, South (again, screen south) is 90. Prime Meridian on the map looks about 10 degrees more than a vertical line, so that's 10 degrees more than 90 in screen rotation, or 110 degrees. So, subtract your degrees variable from 110. Thus, 90 degrees on the screen is 10 degrees on the map.
So,
var primeMeridianRotation = 110
var lattitude = primeMeridianRotation-degrees
// positive lattitude = east lattitude, negative = west lattitude
My numbers here are all guestimates from looking at your map, you would need to figure out the actual pole point, degrees per pixel, and prime meridian rotation. But if the map is not too distorted, this should give you close to accurate lat/long for any point on the map.
Hope this is any help.
Macaquinho
02-22-2006, 09:43 PM
Hy, tried this out.... its a good idea. But the problem is that the degree of the latitude doesnt increase uniformly.
I attached the .fla, maybe someone can help me out.
http://www.megaupload.com/de/?d=KZCRJP01
thx
autogas
03-07-2006, 11:44 AM
i hope someone can help me.
Macaquinho
I saw the solution of this problem.
http://mainmaps.com/fly ( press "SPACE"-key & MouseClick in any point, then you see lat/lon ).
write Him.
http://mainmaps.com/contact.html
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.