views:

48

answers:

1

I've got a map (Mercator), and the coordinates of the 4 corners of the map. I need to come up with something so I can convert given coordinates to corresponding points on the map. I can't use google or anything of the sort, which is why I'm needing to do this in the first place.

The languages I can use are either going to be PHP or Javascript. I've tried some things that I've found in other posts such as this one: http://stackoverflow.com/questions/2103924/mercator-longitude-and-latitude-calculations-to-x-and-y-on-a-cropped-map-of-the, but I haven't had any luck with them.

If anyone can offer some assistance I would be really grateful. I'm terrible with math and looking at some of these equations this is starting to feel out of my league, but I've got to get it done.

Again, thank in advance.

A: 
   function convert_coords($lat, $lon)
     {
   $width = 1281;
   $height = 1529;
// X and Y boundaries
$westLong = -75.196438;
$eastLong = -74.674072;
$northLat = 41.377581;
$southLat = 40.909232;

$lat = $lat;
$lon = $lon;

 $x = $width * (($westLong-$lon)/($westLong-$eastLong));
 $y = ($height * (($northLat-$lat)/($northLat-$southLat)));

    echo $x."<br />";
    echo $y;

}

This is what I've been trying to get to work. It's a variation of something I pulled off here, I think, but it doesn't get me the results I need. I've really run into a brick wall with this one badly. And there is no way on earth I'm going to figure out the math here on my own, I've been trying and it's way out of my league.

EJ Lennox