-1

I have a static image of a map in my country and need to place icons on it dynamically, of which i have Longitude and Latitude information. Is there some formula for this kind of translation or any library for such a problem?

riccardolardi
  • 1,713
  • 5
  • 20
  • 35
  • I don't know it is a solution for you but you can overlay image on the google maps and set markers on it based on latitude and longitude. https://developers.google.com/maps/documentation/javascript/examples/maptype-image-overlay – lu cip Oct 09 '13 at 11:57
  • possible duplicate of [Convert lat/lon to pixel coordinate?](http://stackoverflow.com/questions/18838915/convert-lat-lon-to-pixel-coordinate) – Micromega Oct 09 '13 at 13:15

1 Answers1

1

First off, you need to find the map projection because the earth is a sphere. Most likely it's a mercator projection. Then you need to get the corners, i.e. bounding box and height in pixel and width of your map. Then you can apply the mercator formula with each point: Convert lat/lon to pixel coordinate?. Or you can use proj4.

Community
  • 1
  • 1
Micromega
  • 12,486
  • 7
  • 35
  • 72
  • what do you mean with "find the map projection"? i got the long/lat information over google map geocoder function... does this give any info about the projection? – riccardolardi Oct 09 '13 at 12:14
  • I am now using this formula: http://stackoverflow.com/a/10401734/1515187 and it seems like it is working, I just have a slight offset to the left and bottom, could this have to do with map projection type mismatch? – riccardolardi Oct 09 '13 at 12:43
  • it is working now with the technique i mentioned in the past comment, i just forgot to substract the offset of the icon! thanks anyways – riccardolardi Oct 09 '13 at 14:26