[mapserver-users] Can anyone help me please???/
ramya srinivasan
hellomps at gmail.com
Thu Aug 28 04:01:33 PDT 2008
HI,
I have to display the user clicked point on the map. But i don get the
point in the map.. Can any one please correct my code..
<?php
dl('php_mapscript.dll');
// Default values and configuration
$map_file="./usa12.map";
$map = ms_newMapObj($map_file);
if ( isset($HTTP_POST_VARS["mapa_x"]) && isset($HTTP_POST_VARS["mapa_y"]))
{
$my_point = ms_newpointObj();
$my_point->setXY($HTTP_POST_VARS["mapa_x"],$HTTP_POST_VARS["mapa_y"]);
$nGeoX = Pix2Geo($my_point->x, 0,$map->width , $map->extext->minx,
$map->extent->maxx, 0);
$nGeoY = Pix2Geo($my_point->y, 0, $map->height, $map->extent->miny,
$map->extent->maxy, 1);
$point=ms_newpointobj();
$point->setXY($nGeoX,$nGeoY);
$layer=$map->getLayerByName("US state boundaries");
if (@$layer->queryByPoint($point,MS_SINGLE ,0) == MS_SUCCESS)
{
$image_from_query=$map->drawQuery();
$image_from_query_url=$image_from_query->saveWebImage();
}
}
function Pix2Geo($nPixPos, $dfPixMin, $dfPixMax, $dfGeoMin, $dfGeoMax,
$nInversePix)
{
$dfWidthGeo = $dfGeoMax - $dfGeoMin;
$dfWidthPix = $dfPixMax - $dfPixMin;
$dfPixToGeo = $dfWidthGeo / $dfWidthPix;
if (!$nInversePix)
$dfDeltaPix = $nPixPos - $dfPixMin;
else
$dfDeltaPix = $dfPixMax - $nPixPos;
$dfDeltaGeo = $dfDeltaPix * $dfPixToGeo;
$dfPosGeo = $dfGeoMin + $dfDeltaGeo;
return ($dfPosGeo);
}
$image=$map->draw();
$image_url=$image->saveWebImage();
?>
map file
MAP
NAME USA1
STATUS ON
SIZE 800 500
IMAGETYPE PNG
IMAGECOLOR 200 200 200
SHAPEPATH "C:\ms4w\Apache\data"
EXTENT -8000000 300000 5000000 1500000
UNITS METERS
PROJECTION
"proj=lcc" "lat_1=32" "lat_2=44" "lat_0=38" "lon_0=-100" "x_0=0"
"y_0=0" "ellps=GRS80" "datum=NAD83"
END
WEB
IMAGEPATH "C:\ms4w\tmp\ms_tmp"
IMAGEURL "C:\ms4w\tmp\ms_tmp"
END
LAYER
NAME "US state boundaries"
TYPE POLYGON
STATUS ON
DATA "statesp020"
PROJECTION
"proj=latlong"
"ellps=GRS80"
"datum=NAD83"
END
CLASS
NAME "US states"
OUTLINECOLOR 175 175 175
COLOR 150 150 150
SYMBOL 0
TEMPLATE "hello.html"
END
END
END
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20080828/87b48d2c/attachment.htm>
More information about the MapServer-users
mailing list