SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Apr 2002
    0 Post(s)
    0 Thread(s)

    Plotting points on a custom map with PHP

    I've been looking into plotting several points on a custom map dynamically with PHP. I found this article: which probably works great for that map, but I'm interested in using my own custom map (USA only).

    Does anyone know how to go about modifying that code so it will scale correctly to my custom map? I'm not looking for any advanced functions such as scrolling or scaling, but rather just want to use my own custom US map instead of the generic world map there. Thanks!

  2. #2
    SitePoint Guru gavwvin's Avatar
    Join Date
    Nov 2004
    Cornwall, UK
    0 Post(s)
    0 Thread(s)
    crop the image in some image-editing program, however you would have to do your best to determine what the long and lat are at the edges of the photo- perhaps crop through some known landmark (49th parallel?) for which you can look up its co-ordinates. You need to know the longitude of both vertcal edges, and the latitude of both horizontal edges. Then replace some lines:

    PHP Code:
       $x = (($lon 180) * ($width 360));
    $y = ((($lat * -1) + 90) * ($height 180)); 
    180 makes it so that the left edge gives 0, so you want to replace with the longitude value of the left edge of your picture (not including -)

    360 is the width of the map in degrees so replace that with the number of degrees long your new map covers horizontally.

    90 is the latitude of the top edge, replace that with the lat of the top edge of your new picture

    The last 180 is the height in degrees, so replace that with the number of degrees long your new map covers vertically.

    I think that should be it, it doesn't look like the second function needs modifying. Let me know how you get on!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts