Coordinate Menu Widget - New !

13942
95
02-17-2011 07:51 PM
Drew
by
Occasional Contributor III
Hello Everyone,
I created a new widget that you might find useful.
Tucked away in the map context menu are three XY operations

   1.     Copy XY
   2.     Project XY (configurable)
   3.     Go To XY

ReadMe.txt included

Hope you find it useful!

Click Here to demo and download the Coordinate Menu Widget

Drew
Tags (2)
0 Kudos
95 Replies
DilsonKitoko
New Contributor III

Hello All,

I know that this topic it's a bit old, but i found this widget very useful. I'm working with compiled and uncompiled version and I have an issue. My application based on Flex 3.6 is in the projected CRS 22033 (Camacupa projected). I'm trying to display coordinates in WGS84 (4326). But when you see the results I figure it out that the coordinates are being converted to another CRS which is 4220 (Camacupa Geographic). There is anyway to set the transformation parameters in the source code? with a specific wkid transformation?

Thanks in advance,

Dilson

0 Kudos
DilsonKitoko
New Contributor III

I would like to hardcode the cod below to use the Datum transformation with WKID 1327. But I don't know exactly how do to it. This code is part of Coord Menu Widget

It's not getting the transformation parameters from geometry service.

#

package widgets.CoordinateMenu

{

import com.esri.ags.SpatialReference;

import com.esri.ags.events.GeometryServiceEvent;

import com.esri.ags.geometry.MapPoint;

import com.esri.ags.tasks.GeometryService;

import com.esri.ags.tasks.supportClasses.ProjectParameters;

import mx.controls.Alert;

import mx.rpc.events.FaultEvent;

public class Projector

{

public var geometryServiceURL:String;

public var geometryService:GeometryService;

public function Projector(geomServiceURL:String)

{

this.geometryServiceURL = geomServiceURL;

}

public function projectPoint(mapPoint:MapPoint, toWKID:Number, callbackFunction:Function, errorFunction:Function = null😞void

{

this.geometryService = new GeometryService(this.geometryServiceURL);

this.geometryService.addEventListener(GeometryServiceEvent.PROJECT_COMPLETE, callbackFunction);

if (errorFunction != null)

{

this.geometryService.addEventListener(FaultEvent.FAULT, errorFunction);

}

else

{

this.geometryService.addEventListener(FaultEvent.FAULT, function():void

{

Alert.show("Error projecting coordinates.","Error");

});

}

var projectParamaters:ProjectParameters = new ProjectParameters();

projectParamaters.outSpatialReference =new SpatialReference(toWKID);

projectParamaters.geometries = [mapPoint];

this.geometryService.project(projectParamaters);

//var outSpatialReference:SpatialReference = new SpatialReference(toWKID);

//this.geometryService.project([mapPoint],outSpatialReference);

}

}

}

0 Kudos
Drew
by
Occasional Contributor III

Dilson... Lets try a few things. 

I think it can be done...  But I don't even have Flex Builder installed anymore to help much.

If we look at the "ProjectParameters" object I see it accepts a datumTransformation

Try adding that ..

Drew

0 Kudos
Drew
by
Occasional Contributor III

Some general steps..

Import the class at the top of the file

STEP 1

import com.esri.ags.tasks.supportClasses.DatumTransform;

STEP 2

Locate the following line

var projectParamaters:ProjectParameters = new ProjectParameters();

STEP 3

Add the new code below the line above

var datumTransform:DatumTransform = new DatumTransform();
     datumTransform.wkid=1327;
projectParamaters.datumTransform = datumTransform;

STEP 4 

Test.

Like i said, I don't even have Flex installed. Play around and see what you can do.

Drew

0 Kudos
Drew
by
Occasional Contributor III

So what is the end result... Is is functioning as expected now?

0 Kudos
DilsonKitoko
New Contributor III

Hi Andrew,

Sorry for not answer before, I was testing the modifications.I can compile the widget, with no error, but It`s still not working.

In fact I've noted that the default function to calculcate WGS84 is not working. It's converting the coordinates to Camacupa GCS (wkid 4220).

And even If i setup in coordinate system tag to calculate WGS84, it's also given as result Camacupa GCS. My map is in Camacupa Projected S33 (wkid:22033) and I able to project to Camacupa / TM 12 SE (wkid:22092), but not to WGS84 and using the transformation with or without the wkid 1327.

For some reason seems like the tool is ignoring the 4326 parameters.

Cheers

0 Kudos
DilsonKitoko
New Contributor III

Hello,

It's working now Andrew, after I add the following lines:

projectParameters.datumTransform = datumTransform;

projectParameters.transformForward = true;

So my the final of my file is looking like:

var projectParameters:ProjectParameters = new ProjectParameters();

var datumTransform:DatumTransform = new DatumTransform();

      datumTransform.wkid=1327;

 projectParameters.datumTransform = datumTransform;

projectParameters.transformForward = true;

projectParameters.outSpatialReference =new SpatialReference(toWKID);

projectParameters.geometries = [mapPoint];

this.geometryService.project(projectParameters);

Thank you very much for taking your time to help with this issue, I highly appreciate The tool is still very useful after all this years!

Have a nice day!

Dilson

0 Kudos
Drew
by
Occasional Contributor III

Thanks good to hear. I am glad it worked out. 
Maybe one day i'll release a JS version of it...  I just cant find the time right now

DilsonKitoko
New Contributor III

Hi Andrew, thanks for your prompt reply. I've read that, but when i try to add the following:

public var datumTransform:DatumTransform;

A got the error message "1046: Type was not found or was not a compile-time constant:". Maybe I'm missing to import some library.

Thanks,

Dilson

0 Kudos
Drew
by
Occasional Contributor III

See step 1 in my post above....

'import com.esri.ags.tasks.supportClasses.DatumTransform;'

0 Kudos