[Chameleon] Convert Map click to LatLong

McGraw, Joanne mcgrawj at AGR.GC.CA
Tue Aug 23 12:23:12 EDT 2005


G'day everyone,

I am trying to convert the coordinates of a mouse click on my map to 
lat/long and am getting some very wrong results. I am using the code
below in a widget's phtml.

The actual projection returned by the Map object's getprojection() is 
commented below the call. The projection x,y values returned by the 
Pix2Geo calls are: -763099.839836, 4721502.26087. I am actually 
clicking in the vicinity of Halifax, Nova Scotia on my map and expect 
to end up with latitude, longitude values: 44.9n, 63.5w (-ish). I am 
getting values of: 32.5, -99.3.

There's gotta be something I'm missing in here, but I've searched the
Chameleon and MapServer archives for clues and haven't found any. 
There was some discussion about ensuring I am using the current (vs. 
the original) map extents, but I believe I am.

Anybody have any ideas?

Cheers,
jtm


$oMap = $oMapSession->oMap;
$szMapProj = $oMap->getprojection();
// +proj=lcc +lat_0=0 +lat_1=49 +lat_2=77 +lon_0=-91.8666 +datum=NAD83

$aszMinMax = explode(";", $_FORM["NAV_INPUT_COORDINATES"]);
$adMin = explode(",", $aszMinMax[0]);

$nGeoClickX = Pix2Geo($adMin[0], 0, $oMap->width, $oMap->extent->minx,
                      $oExt->maxx, 0);
$nGeoClickY = Pix2Geo($adMin[1], 0, $oMap->height, $oMap->extent->miny,
                      $oExt->maxy, 1);

// nGeoClickX, nGeoClickY : - -763099.839836, 4721502.26087

reprojectPoint($nGeoClickX, $ nGeoClickY, $szMapProj, "+proj=latlong
+datum=NAD83");

// nGeoClickX, nGeoClickY : -99.2798739088, 32.5284181064




More information about the Chameleon mailing list