Another article which is taking a brief step back in time. The main point of this example is to show how you can use the functions we defined eariler to plot a number of points on a map instead of just a single one.
We are storing the points we want to plot ( as it happens a list of volcanoes ) in a text file. The records are CR/LF delimited. The columns in the list are separated with a space ( 0x20 ). For example -
To load the file into an array we are using the file function. This PHP function will load a CR/LF delimited file directly into an array, saving us a lot of overhead. To extract the columns we explode each element in the array.
To finish, we just add a loop to convert and plot each point in the array using our mighty getlocationcoords. The code here has been reduced - all the files you need to run and generate the example image are included in the ZIP file downloadable from the link below.
// We are assuming getlocationcoords is included somewhere else.
// First we load the text file containing the coordinated
$coord_array = file("vol.txt");
// This is our source raster file. For this example we are
// using a larger file
$im = imagecreatefromjpeg("earth_620.jpg");
$red = imagecolorallocate ($im, 255,0,0);
$scale_x = imagesx($im);
$scale_y = imagesy($im);
// Loop though each element of the array loaded from the
// text file
foreach($coord_array as $value)
// Explode out the latitude and longitude coordinates
$co = explode(" ",$value);
// And we have done all this before ......
$pt = getlocationcoords($co, $co, $scale_x, $scale_y);
// Return the image as a JPEG - it would be @ 230k as PNG!