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
plus the size of the base map and return the screen coordinates in an associative
array.
size of the background image. In future projects these variables are used scale
the map and set the zoom level.
getlocationcoords
. This takes the longitude and latitude coordinatesplus the size of the base map and return the screen coordinates in an associative
array.
$width
and $height
are calculated from thesize of the background image. In future projects these variables are used scale
the map and set the zoom level.
<?php
function getlocationcoords($lat, $lon, $width, $height)
{
$x = (($lon + 180) * ($width / 360));
$y = ((($lat * -1) + 90) * ($height / 180));
return array("x"=>round($x),"y"=>round($y));
}
?>
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.
on the base map using the returned array to mark our location.