Select to view content in your preferred language

geometryservice projectcomplete returns null value on first map click event

2533
1
09-28-2011 06:36 PM
eddiequinlan
Deactivated User
Hi All,

This should be an easy fix that I'm overlooking.  My app use to display the state plane coordinates after converting from the Mercator projection.  I made some changes and now can't get it to work properly.

The geometry service is working properly and converting the map point.  However, i can't "keep" that converted value to a variable to be used else where in my app.  After the "projectcomplete" of the geometryservice is finished, it looses the value.

If the map is clicked again, it get's the previous value from the previous map click event.

I've tried everything, except the correct thing........ I've set global [bindable] variables, passed the variable as a 'return' after the projectcomplete event....... nothing.

Help, I'm loosing my hair!
Eddie

public function reProject(coord:MapPoint):void
{
    try
    {
    
     //myGeoService is set in the declarations..................
     //  All variables are set and working..............................

      myGeoService.project([coord as Geometry], outSR);
    
    
     //Alert.show(processedpt.toString());
    
   }
      catch (error:Error)
   {
    Alert.show("DecimaltoDMS.as error  " + error.toString());  // gives null value on first map click
  }
   //Alert.show(processedpt.toString());    // gives null value on first map click
}
  
 
private function ConvertCoord (event:GeometryServiceEvent):void
{
    pt = (event.result as Array)[0]as MapPoint;

    //processedpt = pt  // or same results next line   
    processedpt = new MapPoint(pt.x, pt.y, pt.spatialReference);
   
    Alert.show(processedpt.toString());  //   This displays the correct converted map points!!!!!   
}
Tags (2)
0 Kudos
1 Reply
eddiequinlan
Deactivated User
After further investigation, it appears to me that no variables can be set and used outside of the
GeometryService projectcomplete handler.

private function ConvertCoord (event:GeometryServiceEvent):void
{
     pt = (event.result as Array)[0]as MapPoint;

     //processedpt = pt // or same results next line
     processedpt = new MapPoint(pt.x, pt.y, pt.spatialReference);

     Alert.show(processedpt.toString()); // This displays the correct converted map points!!!!!
}

Any variables I try to set within this function (specifically the MapPoint) is not accessible outside the function until the event is completed.  Running another function after this one is complete, does return the correct MapPoint.  However, I need the MapPoint set within this function; Any ideas?

Eddie
0 Kudos