开发者

How to find pixel coordinates of a city on a world map using longitude and latitude?

I have a world map that is 800px wide and 340px high. How can I find the position of a city like, for example, New York with latitude 40.75 and longitude -73.98? I would like to pin a marker over this point.

So far I have 开发者_运维百科been adding cities manually which is problematic.

Is there any way to convert latitude and longitude values to x and y coordinates?

Thank you


From this image, you can see the coordinate system for latitude and longitude:

How to find pixel coordinates of a city on a world map using longitude and latitude?

Unless you know the exact location (both pixel-wise and latitude and longitude) of a point on your map, you can't do anything with it. You just won't have enough information.

By x axis and y axis, do you refer to your image? What is the image of (like the whole world, or of a specific region)?

If it's of the whole world, then the coordinates would be:

  • x = image.width * (longitude + 180) / (2 * 180)
  • y = image.height * (latitude + 180) / (2 * 180)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜