[mapserver-users] need help getting pan button in php to work
Joe Nannery
joealan at sbcglobal.net
Mon Mar 31 12:06:42 PDT 2008
Hey all,
I am new to working with phpmapscript...i've used the PHPMapscript example at mapserver.gis.umn.edu, and have found a code snippet for an arrow (function panarrow()), however when i try to get it to work with an input button in html the map just refreshes itself. what changes should I make? thanks.
<?php
dl('php_mapscript.dll');
$val_zsize=3;
$check_pan="CHECKED";
$map_path="c:/ms4w/apache/htdocs/geog490/";
$map_file="terrehaute.map";
$map = ms_newMapObj($map_path.$map_file);
if ( isset($HTTP_POST_VARS["mapa_x"]) && isset($HTTP_POST_VARS["mapa_y"])
&& !isset($HTTP_POST_VARS["full"]) ) {
$extent_to_set = explode(" ",$HTTP_POST_VARS["extent"]);
$map->setextent($extent_to_set[0],$extent_to_set[1],
$extent_to_set[2],$extent_to_set[3]);
$my_point = ms_newpointObj();
$my_point->setXY($HTTP_POST_VARS["mapa_x"],$HTTP_POST_VARS["mapa_y"]);
$my_extent = ms_newrectObj();
$my_extent->setextent($extent_to_set[0],$extent_to_set[1],
$extent_to_set[2],$extent_to_set[3]);
$zoom_factor = $HTTP_POST_VARS["zoom"]*$HTTP_POST_VARS["zsize"];
if ($zoom_factor == 0) {
$zoom_factor = 1;
$check_pan = "CHECKED";
$check_zout = "";
$check_zin = "";
} else if ($zoom_factor < 0) {
$check_pan = "";
$check_zout = "CHECKED";
$check_zin = "";
} else {
$check_pan = "";
$check_zout = "";
$check_zin = "CHECKED";
}
$val_zsize = abs($zoom_factor);
$map->zoompoint($zoom_factor,$my_point,$map->width,$map->height,
$my_extent);
}
function panarrow ($map, $HTTP_POST_VARS) {
$xmax = intval($HTTP_POST_VARS["maxx"]); // E
$xmin = intval($HTTP_POST_VARS["minx"]); // W
$xinc = ($maxx - $minx ) / 5; // pan-factor
$ymax = intval($HTTP_POST_VARS["maxy"]); // S
$ymin = intval($HTTP_POST_VARS["miny"]); // N
$yinc = ($maxy - $miny ) / 5; // pan-factor
// which button is pressed
if ( isset($HTTP_POST_VARS["panN_x"])) {
$map->setextent( $minx, ($miny + $yinc), $maxx, ($maxy +$yinc));
}
elseif ( isset($HTTP_POST_VARS["panS_x"])) {
$map->setextent( $minx, ($miny - $yinc), $maxx, ($maxy - $yinc));
}
elseif ( isset($HTTP_POST_VARS["panW_x"])) {
$map->setextent( ($minx - $xinc), $miny, ($maxx - $xinc),$maxy);
}
elseif ( isset($HTTP_POST_VARS["panE_x"])) {
$map->setextent( ($minx + $xinc), $miny, ($maxx + $xinc),$maxy);
}
}
$image=$map->draw();
$image_url=$image->saveWebImage();
$extent_to_html = $map->extent->minx." ".$map->extent->miny." "
.$map->extent->maxx." ".$map->extent->maxy;
//////////////////here's the html where I bring up the arrow:
<tr><td>Pan North</td>
<td><input type="submit" name="pan north" value="pan north" <?php echo $panN?> ></td></tr>
Joe Nannery
Joealan at sbcglobal.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20080331/1984b8d2/attachment.htm>
More information about the MapServer-users
mailing list