[mapguide-users] OnPointDigitized and GetTransform

Mark Pendergraft markp at Meadgilman.com
Tue Feb 3 14:58:04 EST 2009

I have a utility that accomplishes what you are trying to do, and I
convert to lat/long using this code snippet (in vb.net)
Assume you have variables X,Y which are doubles.

        Dim geoFact As New MgGeometryFactory
        Dim coord As MgCoordinate = geoFact.CreateCoordinateXY(X, Y)
        Dim coordFact As New MgCoordinateSystemFactory
        Dim coordSys As MgCoordinateSystem      
        coordSys = coordFact.Create(Map.GetMapSRS)
        Dim LLcoord As MgCoordinate = coordSys.ConvertToLonLat(coord)

	  link = "http://maps.google.com?q=" + LLcoord.Y.ToString + ","
+ LLcoord.X.ToString

I hope that helps.
Also, you don't really need an API key to do this.  My function just
puts together a link, and then uses javascript to open it in a new

-Mark P.

-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Steve G
Sent: Tuesday, February 03, 2009 11:47 AM
To: mapguide-users at lists.osgeo.org
Subject: Re: [mapguide-users] OnPointDigitized and GetTransform

I have searched through the Nabble forum to find some sample codes, so I
of understand what you mean.  However, I have also found that
MgCoordinateSystemTransform is now an abstract class.  I have modified
code to what I think would work:

        $coordSysFactory = new MgCoordinateSystemFactory(); 

        // Define a Target Coordinate System
        $source = $coordSysFactory->Create($mapGetMapSRS()); 

        // Define a Target Coordinate System
        $LLWGS84 ='PROJCS["LL-WGS84",

        $source = $coordSysFactory->Create($map->GetMapSRS()); 
        $target = $coordSysFactory->Create($LLWGS84); 
        $transform = new MgCoordinateSystemTransform($source, $target); 

And then the following code with the digitizepoint function.  

 function DigitizePoint() {
          // ShowResults("");
      function OnPointDigitized(point) {
          ShowResults("X: " + point.X + ", Y: " + point.Y);

However, I am not sure how to combine the two code snipets into one PHP
file?  You said something about "call Transform() passing in your
points", can you explain a little more or perhaps showing me how this
be written in the code?  Just having some difficulties with my limited
understanding and programming background.  Thanks again!!!

Also, does anyone know if the Web Mercator Projection works?:


Jackie Ng wrote:
> GetTransform() requires two MgCoordinateSystem objects. These are
> from the MgCoordinateSystemFactory, which you have to pass in wkt
> of the coordinate systems.
> So you need 2 wkt strings:
> 1) The map's coordinate system (The GetMapSRS() method of MgMap will
> return this string)
> 2) The WGS84 coordinate system (You'll have to find this string
> Then with the MgCoordinateSystemTransform object obtained from
> GetTransform(), call Transform() passing in your digitized points,
> will then return the transformed points (in WGS84)
> - Jackie
> Steve G wrote:
>> I am trying to create a tool in the task pane where you click a
>> and then click on the map which will get the x, y coordinates and
open in
>> google maps.  I have found the sample onpointdigitized php example
>> copied the code and it works pretty well to get the x, y coordinates.

>> The next step is that my map is in state plane california III (feet)
>> projection, so the map units (feet) do not correlate to google maps
>> (WGS84, decimal degrees).  I know there is the GetTransform()
>> but I haven't been able to figure out how to implement the code (put
>> all together with the onpointdigitized).  I was wondering if anyone
>> provide some help.  It's basically joining the two together and then
>> sending the code to google maps (I already got an API key).  
>> Any help would greatly be appreciated (I am more of a GIS user than
>> programmer)!
>> Thanks,
>> -Steve

View this message in context:
Sent from the MapGuide Users mailing list archive at Nabble.com.

mapguide-users mailing list
mapguide-users at lists.osgeo.org

More information about the mapguide-users mailing list