[Chameleon] Convert Map click to LatLong
McGraw, Joanne
mcgrawj at AGR.GC.CA
Wed Aug 24 12:42:08 EDT 2005
All it takes is another set of eyes!!
Jason,
Thank you very much for pointing out that in the following two lines I
was using an $oExt object I hadn't initialized.
$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);
Too much cutting and pasting going on, I think. Anyway, the fixed code
is:
$nGeoClickX = Pix2Geo($adMin[0], 0, $oMap->width, $oMap->extent->minx,
$oMap->extent->maxx, 0);
$nGeoClickY = Pix2Geo($adMin[1], 0, $oMap->height, $oMap->extent->miny,
$oMap->extent->maxy, 1);
And all works beautifully.
Thanks again, Jason.
Jtm
Ps. To answer Jason's question from below, the projection coordinates
were not correct; so, obviously, the lat/longs couldn't be.
-----Original Message-----
From: chameleon-bounces at lists.maptools.org
[mailto:chameleon-bounces at lists.maptools.org] On Behalf Of Jason
Fournier
Sent: Tuesday, August 23, 2005 9:16 PM
To: chameleon at lists.maptools.org
Subject: Re: [Chameleon] Convert Map click to LatLong
Joanne,
Are -763099.839836, 4721502.26087 the correct coordinates of Halifax for
your native projection?
Would it be possible to post your widget code to the list?
Thanks,
Jay
McGraw, Joanne wrote:
> 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
>
>
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
>
--
________________________
Jason Fournier
DM Solutions Group Inc.
jfournier at dmsolutions.ca
www.dmsolutions.ca
613.565.5056 x18
_______________________________________________
Chameleon mailing list
Chameleon at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/chameleon
More information about the Chameleon
mailing list