More tweaks to get the map working. At the moment, the clickable area is off because it's not scaled like the actual image is. I'll have to work on that next.

git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@34 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-05-29 03:36:28 +00:00
parent 2b135b0e66
commit 44bdb384f5
2 changed files with 41 additions and 20 deletions

View File

@@ -42,7 +42,7 @@ class MapsController extends AppController {
* - Produces a PNG site map image * - Produces a PNG site map image
*/ */
function map($id = null, $requested_width = 600) { function map($id = null, $requested_width = 800) {
if (!$id) { if (!$id) {
$this->Session->setFlash(__('Invalid Item.', true)); $this->Session->setFlash(__('Invalid Item.', true));
$this->redirect(array('action'=>'index')); $this->redirect(array('action'=>'index'));
@@ -235,14 +235,14 @@ class MapsController extends AppController {
*****/ *****/
// Scale things according to desired display width // Scale things according to desired display width
$screen_adjustment_factor = $requested_width / $info['extents']['right'];; $screen_adjustment_factor = $requested_width / $info['extents']['right'];
// Define image size // Define image size
$info['width'] = $info['extents']['right'] * $screen_adjustment_factor; $info['width'] = $info['extents']['right'] * $screen_adjustment_factor;
$info['depth'] = $info['extents']['bottom'] * $screen_adjustment_factor; $info['depth'] = $info['extents']['bottom'] * $screen_adjustment_factor;
// Go through each unit, adjusting map locations // Go through each unit, adjusting map locations
foreach ($info['units'] AS $unit) { foreach ($info['units'] AS &$unit) {
$unit['left'] *= $screen_adjustment_factor; $unit['left'] *= $screen_adjustment_factor;
$unit['right'] *= $screen_adjustment_factor; $unit['right'] *= $screen_adjustment_factor;
$unit['top'] *= $screen_adjustment_factor; $unit['top'] *= $screen_adjustment_factor;
@@ -255,7 +255,6 @@ class MapsController extends AppController {
} }
?> ?>

View File

@@ -1,24 +1,46 @@
<?php /* -*- mode:PHP -*- */ ?> <?php /* -*- mode:PHP -*- */ ?>
<DIV> <DIV class="map">
<?php <MAP name="mapzones"><?php
echo $html->image(array('controller' => 'maps', {// for indentation purposes
'action' => 'map', // Go through each unit, adding a clickable region for the unit
$info['map_id']), foreach ($info['units'] AS $unit){
array('alt' => 'Site Map', echo(' <area shape="rect"' .
'class' => 'imagemap', ' coords="' .
'usemap' => '#mapimg')); $unit['left'] . ',' .
?> $unit['right'] . ',' .
$unit['top'] . ',' .
$unit['bottom'] .
'" href="' .
$html->url(array('controller' => 'units',
'action' => 'view',
$unit['id'])) .
'" alt="' .
$unit['name'] .
'">' . "\n");
}
}// for indentation purposes
?>
</MAP>
<?php
echo $html->image(array('controller' => 'maps',
'action' => 'map',
$info['map_id']),
array('alt' => 'Site Map',
'class' => 'map',
'usemap' => '#mapzones'));
?>
</DIV> </DIV>
<DIV> <DIV class="legend">
<?php <?php
/* echo $html->image(array('controller' => 'maps',
$html->image(array('controller' => 'maps', 'action' => 'legend',
'action' => 'legend', $info['map_id']),
$map['Map']['id']), array('alt' => 'Site Map Legend',
array('alt' => 'Site Map Legend')); 'class' => 'map'));
*/
?> ?>
</DIV> </DIV>