The following messy code implements a decent hex map, but I have no way to detect edges and corners:
function blankMap($scenario_array){
$hexMap = null;
$hexCss = "<style media=\"screen\" type=\"text/css\">#map {
position: relative;}
#map li {
margin: 0; padding: 0; list-style: none;
position: absolute;}
#map li, #map a {
height: 300px; display: block;}";
$hexCount = 1;
$row = 1;
$top = 0;
$left_pad = 10;
$first_fifth = 0;
$second_fourth = 0;
if($scenario_array[0] == 'basic'){
$hexMap .= "<ul id=\"map\">";
foreach($scenario_array[1] as $x){
//set horizontal placement
$first_fifth = 149;
$second_fourth = 75;
if($row == 1){
$left_pad = $first_fifth;
}elseif($row == 2){
$left_pad = $second_fourth;
}elseif($row == 3){
$left_pad = 0;
}elseif($row == 4){
$left_pad = $second_fourth;
}elseif($row == 5){
$left_pad = $first_fifth;
}
for($i=0;$i<$x;$i++){
$hexMap .= "<li id=\"hex".$hexCount."\"><a href=\"".$hexCount."\"></a></li>";
$hexCss .= "#hex".$hexCount." {left: ".(($i*150)+$left_pad)."; width: 225px; top: ".$top."; background: url(./images/wheattile.png); background-repeat: no-repeat; }";
$hexCount++;
}
$row++;
$top += 127;
}
$hexMap .= "</ul>";
$hexCss .= "</style>";
echo $hexCss.$hexMap;
}
}
How do I move on from here so that I can click on edges and corners of the hexes?