Personal tools
You are here: Home Documentation Links GMap PHP/Mapscript Sample Application

GMap PHP/Mapscript Sample Application

Document Actions
A full PHP/Mapscript application available for download, includes data, mapfile, and all php files. Also available as an MS4W package.

Link: http://www.maptools.org/dl/gmap-ms46.zip

This Link applies to: Any version.

by Jeff McKenna last modified 2005-12-22 09:48
Contributors: Yewondwossen Assefa

how to include routing php/mapscript

Posted by ari sutanto at 2007-09-08 23:51
Hi jeff,
I'm using php mapscript from sample of routing application.
The script was look like this :
<?php
dl("php_mapscript.dll");

define("MAPFILE","../maps/routing.map");

$start=0;
$end=0;
$cx1=0;
$cy1=0;
$cx2=0;
$cy2=0;

if($HTTP_GET_VARS["start"])
$start=$HTTP_GET_VARS["start"];

if($HTTP_GET_VARS["end"])
$end=$HTTP_GET_VARS["end"];

if($HTTP_GET_VARS["cx1"])
$cx1=$HTTP_GET_VARS["cx1"];

if($HTTP_GET_VARS["cx2"])
$cx2=$HTTP_GET_VARS["cx2"];

if($HTTP_GET_VARS["cy1"])
$cy1=$HTTP_GET_VARS["cy1"];

if($HTTP_GET_VARS["cy2"])
$cy2=$HTTP_GET_VARS["cy2"];


$delta=0.01;

$map_file=MAPFILE;
$map=ms_newMapObj($map_file);

$l=$map->getLayerByName("network");
if($l) {
if($l && $start!=0 && $end!=0) {

if($cx1!=0 && $cy1!=0 && $cx2!=0 && $cy2!=0 &&
$cx1!=$cx2 && $cy1!=$cy2) {
$minx = min($cx1,$cx2)-$delta;
$miny = min($cy1,$cy2)-$delta;
$maxx = max($cx1,$cx2)+$delta;
$maxy = max($cy1,$cy2)+$delta;

$map->setextent($minx,$miny,$maxx,$maxy);

$rectobj = $map->extent;
$ll_x = $rectobj->minx;
$ll_y = $rectobj->miny;
$ur_x = $rectobj->maxx;
$ur_y = $rectobj->maxy;

$sql="the_geom from (select gid, the_geom from "."shortest_path_astar2_as_geometry_internal_id_directed('tercepat', ".$start.", ".$end.", ".$ll_x.", ".$ll_y.", ".$ur_x.", ".$ur_y.", false, true)) as g using unique gid using SRID=-1";

$l->set('data', $sql);
$l->set('status', MS_ON);

}
}
else {
$l->set('status', MS_OFF);
}
}
$image=$map->draw();
$image_url=$image->saveWebImage();

?>

Then I try to add this script at first php sections of gmap75.phtml,
but the result of that routing script didn't appear in my map window, it just shown in ms4w temp folder.

So The question is how to include this routing application in gmap template?.

Note : my gmap75.phtml using java mode only.

Powered by Plone