The map is working quite well now, including the legend. Next steps will be to add the sidemenu.

git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@36 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-05-29 05:10:46 +00:00
parent 77c038e880
commit 50449205b4
3 changed files with 30 additions and 18 deletions

View File

@@ -79,7 +79,7 @@ class MapsController extends AppController {
// Get the overall site limits, and then compute the // Get the overall site limits, and then compute the
// actual boundary extents, adjusting for a border // actual boundary extents, adjusting for a border
$boundary_adjustment = 5; $boundary_adjustment = 12;
$bottom = 2*$boundary_adjustment + $map['Map']['depth']; $bottom = 2*$boundary_adjustment + $map['Map']['depth'];
$right = 2*$boundary_adjustment + $map['Map']['width']; $right = 2*$boundary_adjustment + $map['Map']['width'];
@@ -158,13 +158,15 @@ class MapsController extends AppController {
$cols = 6; $cols = 6;
$rows = (int)((count($status) + $cols - 1) / $cols); $rows = (int)((count($status) + $cols - 1) / $cols);
$info = array('units' => array(), 'legend' => array()); $info = array('units' => array());
// Get the overall site limits, and then compute the // Get the overall site limits, and then compute the
// actual boundary extents, adjusting for a border // actual boundary extents, adjusting for a border
$boundary_adjustment = 2; $boundary_adjustment = 1;
$bottom = 2*$boundary_adjustment + $cols*360; $item_width = 40; // Absolute values are irrelevant, as they
$right = 2*$boundary_adjustment + $rows*120; $item_depth = 10; // will be scaled in the end anyway.
$bottom = 2*$boundary_adjustment + $rows*$item_depth;
$right = 2*$boundary_adjustment + $cols*$item_width;
// Scale things according to desired display width // Scale things according to desired display width
$screen_adjustment_factor = $requested_width / $right; $screen_adjustment_factor = $requested_width / $right;
@@ -173,19 +175,28 @@ class MapsController extends AppController {
$info['width'] = $right * $screen_adjustment_factor; $info['width'] = $right * $screen_adjustment_factor;
$info['depth'] = $bottom * $screen_adjustment_factor; $info['depth'] = $bottom * $screen_adjustment_factor;
// Get a starting point for our top left position.
$top = $lft = $boundary_adjustment; $top = $lft = $boundary_adjustment;
// Scale it appropriately.
$top *= $screen_adjustment_factor;
$lft *= $screen_adjustment_factor;
$item_width *= $screen_adjustment_factor;
$item_depth *= $screen_adjustment_factor;
foreach ($status AS $code => $color) { foreach ($status AS $code => $color) {
$info['units'][] = array('name' => $code, $info['units'][] = array('name' => $code,
'status' => $code, 'status' => $code,
'width' => $info['legend']['width'], 'width' => $item_width,
'depth' => $info['legend']['depth'], 'depth' => $item_depth,
'left' => $lft, 'left' => $lft,
'right' => $lft + $info['legend']['width'], 'right' => $lft + $item_width,
'top' => $top, 'top' => $top,
'bottom' => $top + $info['legend']['depth']); 'bottom' => $top + $item_depth);
$top += $info['legend']['depth']; $top += $item_depth;
if ($top >= $info['legend']['depth'] * $rows) { if ($top >= $item_depth * $rows) {
$top = $boundary_adjustment; $lft += $info['legend']['width']; $top = $boundary_adjustment * $screen_adjustment_factor;
$lft += $item_width;
} }
} }

View File

@@ -21,7 +21,7 @@ foreach ($info['palate'] AS &$area) {
} }
} }
if ($info['border']) { if (isset($info['border'])) {
// Create border around image // Create border around image
imageline($image, imageline($image,
0, 0, 0, 0,
@@ -68,14 +68,14 @@ foreach ($info['units'] AS $unit) {
// If the unit is wide enough, run the text horizontal, // If the unit is wide enough, run the text horizontal,
// otherwise, we'll have to run it vertical. // otherwise, we'll have to run it vertical.
if ($unit['width'] > 100) { if ($unit['width'] > 40 || ($unit['width'] >= $unit['depth'])) {
imagestring($image, 1, imagestring($image, $unit['width']/25,
$unit['left']+3, $unit['top']+3, $unit['left']+3, $unit['top']+3,
$unit['name'], $unit['name'],
$info['palate']['unit'][$unit['status']]['fg']['color']); $info['palate']['unit'][$unit['status']]['fg']['color']);
} }
else { else {
imagestringup($image, 1, imagestringup($image, $unit['depth']/25,
$unit['left']+3, $unit['bottom']-3, $unit['left']+3, $unit['bottom']-3,
$unit['name'], $unit['name'],
$info['palate']['unit'][$unit['status']]['fg']['color']); $info['palate']['unit'][$unit['status']]['fg']['color']);

View File

@@ -31,6 +31,7 @@
$info['width']), $info['width']),
array('alt' => 'Site Map', array('alt' => 'Site Map',
'class' => 'map', 'class' => 'map',
'border' => 0,
'usemap' => '#mapzones')); 'usemap' => '#mapzones'));
?> ?>
@@ -41,9 +42,9 @@
echo $html->image(array('controller' => 'maps', echo $html->image(array('controller' => 'maps',
'action' => 'legend', 'action' => 'legend',
$info['map_id'], $info['map_id'],
$info['width']), $info['width']/2),
array('alt' => 'Site Map Legend', array('alt' => 'Site Map Legend',
'class' => 'map')); 'class' => 'legend'));
?> ?>
</DIV> </DIV>