Solved

Posted on 2011-05-12

Hi,

I have a map in image format (.png file). I need to point Pins on the map based on the places latitude and longitude information.

If the coordinates are in X, Y instead of latitude and longitude, then I can point easily.

How do I convert the given lat and long to x, y coordinates? My map has different zoom level. For each zoom level, there is a separate map.

For example, I have the Bangalore map, I want to point Jayanagar on the map. I know the lat and long of Jayanagar. In addition to that, Bangalore map has 3 zoom levels. How can I convert the lat and long coordinates to x and y coordinates so that I can point Jayanagar on the map? The point should be visible in all the zoom levels.

I have a map in image format (.png file). I need to point Pins on the map based on the places latitude and longitude information.

If the coordinates are in X, Y instead of latitude and longitude, then I can point easily.

How do I convert the given lat and long to x, y coordinates? My map has different zoom level. For each zoom level, there is a separate map.

For example, I have the Bangalore map, I want to point Jayanagar on the map. I know the lat and long of Jayanagar. In addition to that, Bangalore map has 3 zoom levels. How can I convert the lat and long coordinates to x and y coordinates so that I can point Jayanagar on the map? The point should be visible in all the zoom levels.

8 Comments

Therefore I suggest you pick a distinguished feature (a street crossing etc.) near each corner of the picture, determine both its x,y-coordinates from the map picture and the lat,lan-coordinates by looking up the feature e.g. at www.openstreetmap.org (or google earth if no legal issues speak against that).

Then use simple linear interpolation for the complete picture. This should work as long as the map does not show too big a portion of the earth, or is located too close to one of the poles. With minor adjustions this would even work around the 180° meridian.

Regarding the zoom levels: You did not specify the magnification steps between levels, so you may want to repeat the process described above for all levels.

With most usual maps, the method can be reduced to measuring only two diagonally opposite vertices of the map.

I looked at the below url which may solve my problem

http://board.flashkit.com/

//////////////////////////

// convert lat/long to radians

latitude = Math.PI * latitude / 180;

longitude = Math.PI * longitude / 180;

// adjust position by radians

latitude -= 1.570795765134; // subtract 90 degrees (in radians)

// and switch z and y

xPos = (app.radius) * Math.sin(latitude) * Math.cos(longitude);

zPos = (app.radius) * Math.sin(latitude) * Math.sin(longitude);

yPos = (app.radius) * Math.cos(latitude);

//////////////////////////

In the above formula, what app.radius means?

I searched on this but I could not get the value of it (app.radius in actionscript - adobe flash?)

Can you help me to find app.radius so that I can try out this solution?

x = radius_of_world * Math.cos(longitude) * Math.cos(latitude)

y = radius_of_world * Math.sin(longitude) * Math.cos(latitude)

z = radius_of_world * Math.sin(latitude)

Thanks for all of your support.

To convert the lat and long values to x, y on the map image, first find out the maps four side center points. After finding the center points latitude and longitude, use the below formula to calculate the X and Y position of each place with its lat and long values.

map_X_Constant = width of the map image / (westLeftCenterLongitude - EastRightCenterLongitude);

X = ((westLeftCenterLongitude - PlaceLongitude) * map_X_Constant);

map_Y_Constant = height of the map / (northTopCenterLatitude-so

Y = ((52.695813-PlaceLatitude)

52.695813 - it is a variable factor. You need to try it out with different values to get the x,y point accuracy.

By clicking you are agreeing to Experts Exchange's Terms of Use.

This is a research brief on the potential colonization of humans on Mars.

Join the community of 500,000 technology professionals and ask your questions.

Connect with top rated Experts

**11** Experts available now in Live!