test.php
Code: Alles auswählen
<html>
<body>
<form action="test.php" method="GET">
<input type="image" src="files/php7A9.png" value="Submit" alt="Submit" class="imagemap" style="cursor:crosshair;">
</form>
<?
$image['width'] = 630;
$image['height'] = 291;
$image['path'] = 'files/php7A9.png';
$mark = center_box();
$bf .= '<div style="width:'.$image['width'].'px; height:'.$image['height'].'px; background-image:url('.$image['path'].');">
<div id="in_map" style="position: relative; top:'.$mark['y'].'px; left:'.$mark['x'].'px; border:'.$mark['border'].'; width: 5px; height: 5px; z-index: 99; background-image:url(files/marker.gif);background-repeat: no-repeat;">
</div>';
echo $bf;
?>
</div>
</body>
</html>
<?
function center_box($mark="") {
if(!is_array($mark)) {
//adjust offset
$x_offset = -2;
$y_offset = -22;
$mark = array("x"=>getget("x", 0)+$x_offset,
"y"=>getget("y", 0)+$y_offset,
"border"=>"0px solid red;",
);
}
// $mark['x'] = $mark['x']-ceil($width/2);
// $mark['y'] = $mark['y']-ceil($height/2);
return $mark;
}
function getget($varname, $default="") {
//request a get variable, clean it up, assign a default if false
if (!isset($_GET["$varname"])) $value = $default;
else $value = $_GET["$varname"];
$value=urldecode(trim($value));
return $value;
}
?>
ok, 2 fragen dazu:
- wieso muss ich das $y_offset um ganze 22 pixel korrigieren (selbes problem in ie und ff), damit der marker dann auch dort ist wo ich hingeklickt habe?
- im fertigen projekt will ich die grafik nur einmal anzeigen; dh. der marker sollte idealerweise auf dem button erscheinen - wie mache ich das, der button ist ja kein container element wie das div...?