Select to view content in your preferred language

Polyline with a Map service Query

724
2
Jump to solution
02-17-2014 04:32 AM
EvelynHernandez
Frequent Contributor
Hello.

I have a question. Im trying to get the coords from a Mapservice in Flex through a Query but i dont really know how to put the result from that query into the map to see the Polylines on it.

Im getting the selected "equipo" from a row of a datagrid.
And the map service will return me this :
Polyline:
[-7953213.0725, -3900269.6981999986] , [-7953244.836300001, -3900234.4114999995]

Im doing this.
    function onResult(featureSet:FeatureSet, token:Object = null):void     {      try{              for each (var myGraphic:Graphic in featureSet.features)       {       //do something with the features returned       var mp:MapPoint=featureSet.features[0].geometry as MapPoint;              arrPoints.addItem(mp);              }       var polyLine:Polyline= new Polyline();              polyLine.addPath(arrPoints); //add points to polyline       var g:Graphic = new Graphic(polyLine);       //create new graphic to add to graphicsLayer                     //symbol for line       graphicsLayer.symbol = new SimpleLineSymbol("solid",0xFF3333,1,3);              //add to graphicsLayer       graphicsLayer.add(g);              }catch(err:Error){       Alert.show("no pasa");      }     }



I hope somebody can help me 😞
Thanks for ur time!
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
EvelynHernandez
Frequent Contributor
I did this and it works, u are right.

function onResult(featureSet:FeatureSet, token:Object = null):void
    {
     try{
     
      for each (var myGraphic:Graphic in featureSet.features)
      {
      
      myGraphic.symbol=slsFind;
      graphicsLayer.add(myGraphic);
      acPolyline.addItem(graphicsLayer);
      }
     
     }catch(err:Error){
      Alert.show("no");
     }
    }

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus
Evelyn,

   The Query is returning featureSet.features which is an array of Graphics. So why not just add the graphic to the map instead of what you are trying (which looks like you are trying to iterate over the graphics points and build a polyline graphic, which is already done).
0 Kudos
EvelynHernandez
Frequent Contributor
I did this and it works, u are right.

function onResult(featureSet:FeatureSet, token:Object = null):void
    {
     try{
     
      for each (var myGraphic:Graphic in featureSet.features)
      {
      
      myGraphic.symbol=slsFind;
      graphicsLayer.add(myGraphic);
      acPolyline.addItem(graphicsLayer);
      }
     
     }catch(err:Error){
      Alert.show("no");
     }
    }
0 Kudos