PHPBuilder - GIS Mapping with PHP Page 3

RSS Twitter

GIS Mapping with PHP - Page 3

by: Simon Moss
October 23, 2003

Plots and Schemes

The basic steps for generating the map are:
  • Load the background map.
  • Convert and scale the long/lat coordinates to screen coordinates.
  • Plot the point.
  • Return the finished map as an image.
To convert the long/lat to screen coordinate we have a created a function called getlocationcoords. This takes the longitude and latitude coordinates plus the size of the base map and return the screen coordinates in an associative array. $width and $height are calculated from the size of the background image. In future projects these variables are used scale the map and set the zoom level.

function getlocationcoords($lat$lon$width$height)
$x = (($lon 180) * ($width 360));
$y = ((($lat * -1) + 90) * ($height 180));
    return array(
Once the coordinates have been converted it's as simple as drawing a rectangle on the base map using the returned array to mark our location.

« Previous Page
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Simon Moss



(Maximum characters: 1200). You have characters left.