[mapguide-users] Mapping lat long to screen x y coordinates
julienltr
julienleture at hotmail.com
Fri Sep 7 03:03:59 EDT 2007
julienltr wrote:
>
> I know that AJAX viewer use the JavaScript function "ScreenToMapUnits" to
> translate screen coordinates to map's but I can't find a reverse
> function...
>
I finally find a solution myself. Because we have a ScreenToMapUnits
function in ajaxmappane.templ, it's very easy to do some math to get a
MapUnitsToScreen function :
function MapUnitsToScreen(x, y)
{
xScr = parseInt( (x - extX1) * mapDevW / (extX2 - extX1) );
yScr = parseInt( (y - extY1) * mapDevH / (- extY1 + extY2) );
if(xScr > mapDevW - 1) xScr = mapDevW - 1;
else if(xScr < 0) xScr = 0;
if(yScr > mapDevH - 1) yScr = mapDevH - 1;
else if(yScr < 0) y = 0;
return new Point(xScr, yScr);
}
Problem solved ;)
--
View this message in context: http://www.nabble.com/Mapping-lat-long-to-screen-x-y-coordinates-tf4028110s16610.html#a12537083
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list