0

I have a database with various map locations (latitude, longitude). I've been using a map api (e.g. google maps) to plot these locations.

I am now experimenting to see if I can totally remove dependency of map apis and simply replace the map control with an image (an .png image).

Question: How can I translate the map locations to be displayed properly onto this map image?

More details: Basically, the map will be a rectangular area (i.e. Div element), where the top-left corner of the rectangle is obviously (0, 0). So basically the map locations will be displayed with respect to this top-left corner.

Cœur
  • 37,241
  • 25
  • 195
  • 267
AlvinfromDiaspar
  • 6,611
  • 13
  • 75
  • 140
  • Here is a duplicate question: http://stackoverflow.com/questions/2651099/convert-long-lat-to-pixel-x-y-on-a-given-picure – AlvinfromDiaspar Jan 17 '13 at 21:15
  • Given that you yourself have pointed out the duplicate question, I'm voting this question should be closed – duncan Jan 18 '13 at 11:22

1 Answers1

0

First off, where are you getting your geocodes from? If they are from Bing or Google Maps then you can only use those coordinates with those map controls. Using this coordinates without the map controls is against the terms of use of these API's. Assuming that these coordinates come from somewhere else you can overlay them on an image by first knowing some information about the image. At a minimium you will need to know two coordinates on the image and their relative pixel locations. From that you can then determine the scale and top left coordinate of the image. With this you can then fairly accurately position coordinates on the image using a lot of math. You can find a lot of useful math for this here: http://msdn.microsoft.com/en-us/library/bb259689.aspx I've writing a few blog posts on this a while back which you can find here: http://rbrundritt.wordpress.com/2008/10/25/ve-imagery-service-and-custom-icons/

If these coordinates come from Bing Maps you can easily display them on a map image using the Bing Maps Imagery Service: http://msdn.microsoft.com/en-us/library/ff701724.aspx

rbrundritt
  • 16,570
  • 2
  • 21
  • 46