<div dir="ltr">HI,<br> 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..<br><?php<br>dl('php_mapscript.dll');<br> // Default values and configuration<br>
$map_file="./usa12.map";<br>$map = ms_newMapObj($map_file);<br>if ( isset($HTTP_POST_VARS["mapa_x"]) && isset($HTTP_POST_VARS["mapa_y"]))<br> {<br> $my_point = ms_newpointObj();<br>
$my_point->setXY($HTTP_POST_VARS["mapa_x"],$HTTP_POST_VARS["mapa_y"]);<br> $nGeoX = Pix2Geo($my_point->x, 0,$map->width , $map->extext->minx, $map->extent->maxx, 0);<br>
$nGeoY = Pix2Geo($my_point->y, 0, $map->height, $map->extent->miny, $map->extent->maxy, 1);<br> $point=ms_newpointobj();<br> $point->setXY($nGeoX,$nGeoY);<br>$layer=$map->getLayerByName("US state boundaries");<br>
if (@$layer->queryByPoint($point,MS_SINGLE ,0) == MS_SUCCESS) <br>{ <br>$image_from_query=$map->drawQuery();<br>$image_from_query_url=$image_from_query->saveWebImage();<br>}<br>}<br>function Pix2Geo($nPixPos, $dfPixMin, $dfPixMax, $dfGeoMin, $dfGeoMax, $nInversePix) <br>
{<br> <br> $dfWidthGeo = $dfGeoMax - $dfGeoMin;<br> $dfWidthPix = $dfPixMax - $dfPixMin;<br> <br> <br> $dfPixToGeo = $dfWidthGeo / $dfWidthPix;<br><br> if (!$nInversePix)<br> $dfDeltaPix = $nPixPos - $dfPixMin;<br>
else<br> $dfDeltaPix = $dfPixMax - $nPixPos;<br><br> $dfDeltaGeo = $dfDeltaPix * $dfPixToGeo;<br><br><br> $dfPosGeo = $dfGeoMin + $dfDeltaGeo;<br> <br> <br> <br> return ($dfPosGeo);<br> <br>
}<br> $image=$map->draw();<br> $image_url=$image->saveWebImage();<br>?><br>map file<br>MAP<br> NAME USA1<br> STATUS ON<br> SIZE 800 500<br> IMAGETYPE PNG<br> IMAGECOLOR 200 200 200<br> SHAPEPATH "C:\ms4w\Apache\data"<br>
EXTENT -8000000 300000 5000000 1500000<br> UNITS METERS<br> PROJECTION<br> "proj=lcc" "lat_1=32" "lat_2=44" "lat_0=38" "lon_0=-100" "x_0=0" "y_0=0" "ellps=GRS80" "datum=NAD83"<br>
END<br> WEB<br> IMAGEPATH "C:\ms4w\tmp\ms_tmp"<br> IMAGEURL "C:\ms4w\tmp\ms_tmp"<br> <br> END<br> <br> LAYER<br> NAME "US state boundaries"<br> TYPE POLYGON<br>
STATUS ON<br> DATA "statesp020"<br> PROJECTION<br> "proj=latlong"<br> "ellps=GRS80"<br> "datum=NAD83"<br> END<br> <br>
CLASS<br> NAME "US states"<br> OUTLINECOLOR 175 175 175<br> COLOR 150 150 150<br> SYMBOL 0<br> TEMPLATE "hello.html"<br> END <br>
END <br> <br>END<br><br></div>