Solved! Go to Solution.
Lefteris,
Based on the field name of Lat and Long, are the coordinates in the point feature Geographic? If so then you need to re-project them to 102100 before you add them to the polyline. Just declaring them as WKID 102100 does not re-project them.
Lefteris,
Looks like you have you lat and Long reversed when you create your map point.
pA.push(new MapPoint(obj.lat,obj.long, new SpatialReference(102100)));MapPoint(Y, X, new SpatialReference(102100)));
private function doQuery():void
{
queryTask.execute(query, new AsyncResponder(onResult, onFault));
function onResult(featureSet:FeatureSet, token:Object = null):void
{
if (featureSet.features.length == 1)
{
myMap.zoomTo(featureSet.features[0].geometry);
}
else if (featureSet.features.length > 1)
{
var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(featureSet.features);
if (graphicsExtent)
{
myMap.extent = graphicsExtent;
}
var m:int;
var pA:Array = [];
var wmp:WebMercatorMapPoint;
for(m=0; m<featureSet.features.length; m++){
wmp = new WebMercatorMapPoint(featureSet.attributes["Long"], featureSet.attributes["Lat"]);
pA.push(wmp);
}
var pLine:Polyline = new Polyline(null, new SpatialReference(102100));
pLine.addPath(pA);
var gra:Graphic=new Graphic(pLine, new SimpleLineSymbol("solid",0xFF3333,1,3), null);
myGraphicsLayer2.add(gra);
}
}
}
Lefteris,
OK, the reason I mentioned that I thought you have your lat and Long reversed when you are creating your map points for the poly line is this. A MapPoint takes an X and a Y (in that order). What you have is:pA.push(new MapPoint(obj.lat,obj.long, new SpatialReference(102100)));
Which equates toMapPoint(Y, X, new SpatialReference(102100)));
Also your attached table shows me that the Lat and Long coordinates are NOT webmercator they are geographic and DO need to be projected.
So here is the code that I would be using:private function doQuery():void { queryTask.execute(query, new AsyncResponder(onResult, onFault)); function onResult(featureSet:FeatureSet, token:Object = null):void { if (featureSet.features.length == 1) { myMap.zoomTo(featureSet.features[0].geometry); } else if (featureSet.features.length > 1) { var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(featureSet.features); if (graphicsExtent) { myMap.extent = graphicsExtent; } var m:int; var pA:Array = []; var wmp:WebMercatorMapPoint; for(m=0; m<featureSet.features.length; m++){ wmp = new WebMercatorMapPoint(featureSet.attributes["Long"], featureSet.attributes pA.push(wmp); } var pLine:Polyline = new Polyline(null, new SpatialReference(102100)); pLine.addPath(pA); var gra:Graphic=new Graphic(pLine, new SimpleLineSymbol("solid",0xFF3333,1,3), null); myGraphicsLayer2.add(gra); } } }["Lat"]);
Lefteris,
The points geometry might be in WebMercator but the attributes of Lat and Long are in Geographic.
So did you test the code I provided? If it worked than you should mark this thread as answered.
Don't forget to click the Mark as answer check on this post and to click the top arrow (promote).
Follow these steps as shown in the below graphic: