jeg lavede dette for en del tid siden men det virker vidst ikke hvis der kommer for mange punkter
<?php
// create the image
$result = mysql_query("SELECT * FROM status WHERE latitude != 'NA' OR longitude != 'NA' GROUP BY latitude, longitude") or die(mysql_error());
header("Content-type: image/png");
$img = imagecreatefromgif("globe3t.gif");
while ($row = mysql_fetch_assoc($result)) {
if ($row['longitude'] != "" && $row['longitude'] != "NA" && $row['latitude'] != "" && $row['latitude'] != "NA") {
$x = round(($row['longitude']+180)*2, 0);
$y = round((180-($row['latitude']+90))*2, 0);
//imagesetpixel($img, $x, $y, $red);
$hitArray[] = $x."|".$y;
}
}
$hitArray = array_count_values($hitArray);
arsort($hitArray);
foreach ($hitArray as $key => $amount) {
//imagesetpixel($img, $x, $y, $red);
list($x, $y) = explode("|", $key);
$hit[] = array('x' => $x, 'y' => $y, 'amount' => $amount);
}
// color scale
$color1 = imagecolorallocate($img, 212, 0, 0);
$color2 = imagecolorallocate($img, 255, 42, 0);
$color3 = imagecolorallocate($img, 255, 85, 0);
$color4 = imagecolorallocate($img, 255, 127, 0);
$color5 = imagecolorallocate($img, 255, 170, 0);
$color6 = imagecolorallocate($img, 255, 212, 0);
$color7 = imagecolorallocate($img, 255, 255, 0);
$level = ceil($hit[0]['amount']/7);
foreach ($hit as $key => $value) {
//imagesetpixel($img, $hit[$key]['x'], $hit[$key]['y'], $color[ceil($hit[$key]['amount']/$level)]);
imagesetpixel($img, $hit[$key]['x'], $hit[$key]['y'], $color7);
imagesetpixel($img, $hit[$key]['x']+1, $hit[$key]['y'], $color7);
imagesetpixel($img, $hit[$key]['x']+1, $hit[$key]['y']+1, $color7);
imagesetpixel($img, $hit[$key]['x'], $hit[$key]['y']+1, $color7);
//print "\$color[".ceil($hit[$key]['amount']/$level)."]";
}
imagepng($img);
imagedestroy($img);
?>
billedet kan du hente her
http://www.freno.dk/eksperten/globe3t.gif