Select to view content in your preferred language

Old Sample viewer with api2.0

879
4
09-07-2010 10:03 AM
StephenJakubiak
Emerging Contributor
Hi,

I am using the old sample flexviewer with the new api 2.0 and am having a problem with the geometry service. I am trying to reproject a point and since I need to send graphics.geometry to the new geometryservice instead of the graphics I am not able to get the attributes from the graphics. I was wondering if anyone has done this before if if anyone has an idea of what to do. In my event.result I only receive a mappoint but cannot seem to get the attributes from the graphic. Is there another way to get the attributes or possibly reproject the point after the data is received.

Thanks
Stephen

Here is my code for the reporject of the points:




private function projectAddressCanid(data:Array):void
   {
    var coordGraphic:Graphic;
    var graphics:Array = [];
    for each (var addrCandidate:AddressCandidate in data)
    {
     if (addrCandidate.score >= minscore)
     {
     
      var icon:String = widgetIcon;
      var title:String = addrCandidate.address.toString(); 
      if (!title)
       title = widgetTitle;
      var content:String = "Score: " +addrCandidate.score.toString();
      var link:String = "";
      var point:MapPoint = addrCandidate.location;
      point.spatialReference = new SpatialReference(26917);
      var infoData:Object =
       {
        icon: icon,
        title: title,
        content: content,
        link: link
       };
      coordGraphic = new Graphic(point, smsPoint,infoData);
     
      graphics.push(coordGraphic.geometry);
     
     }
    }
   
    var outSR:SpatialReference = map.spatialReference;
   
    geometryServiceAddress.project(graphics, outSR);
   
   }
  
  private function projectAddressCompleteHandler(event:GeometryServiceEvent):void
   {
    var recAC:ArrayCollection = new ArrayCollection();
    for each (var g:Graphics in event.result)
    {
     var point:MapPoint = g.geometry as MapPoint;
     var icon:String = g.attributes.icon;
     var title:String = g.attributes.title; 
     var content:String = g.attributes.content;
     var link:String = g.attributes.link;
     var infoData:Object =
      {
       icon: icon,
       title: title,
       content: content,
       link: link,
       point: point,
       geometry: point
      };                
     recAC.addItem(infoData);
    }
   
    wRepeater.dataProvider = recAC;
    this.addSharedData(widgetTitle, recAC);
    showMessage(locationsLabel + " " + recAC.length.toString(), false);
    if (recAC.length > 0)
    {
     showLocation(recAC.getItemAt(0));
    }
   }
Tags (2)
0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus
Stephen,

   The projected geometry array is in the same order that it was sent so you can just loop though your graphics and update the geometry of those graphics with the new projected geometries.
0 Kudos
StephenJakubiak
Emerging Contributor
Thanks Robert very helpful
0 Kudos
StephenJakubiak
Emerging Contributor
Robert,

I was wondering if you had any samples of a reprojection in api 2.0

Thanks

Stephen
0 Kudos
StephenJakubiak
Emerging Contributor
I was able to get this to work by embedding the function and using the same address candidate.

Thanks
Stephen
0 Kudos