Select to view content in your preferred language

how to create a line in FeatureLayer by using actionscript?

790
3
Jump to solution
10-08-2012 01:27 AM
sunjian
Emerging Contributor
I can successfully create a point in a FeatureLayer by using actionscrip. But I can't create a line in the same way.Is there any questions? The code is this:
                                var arr:Array = [];          var pointarr:Array = [];     var point1:MapPoint = new MapPoint(120.43712353832049,31.17295183154354);     point1 = WebMercatorUtil.geographicToWebMercator(point1) as MapPoint;     pointarr.push(point1);          var point2:MapPoint = new MapPoint(120.393407390551,31.21343211585429);     point2 = WebMercatorUtil.geographicToWebMercator(point2) as MapPoint;     pointarr.push(point2);          var point3:MapPoint = new MapPoint(120.303107390551,31.21341211185429);     point3 = WebMercatorUtil.geographicToWebMercator(point3) as MapPoint;     pointarr.push(point3);          var polyline:Polyline = new Polyline();     polyline.addPath(pointarr);          var g:Graphic = new Graphic();     g.geometry = polyline;          arr.push(g);          var response:AsyncResponder = new AsyncResponder(myResultFunction,myFaultFunction);     fea.applyEdits(arr, null, null,false,response); 

It isn't success. So I can't solve the problem. Please help me! Thanks!
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
sunjian
Emerging Contributor
Can you use a tool like HttpFox to see what the response from the server is?


I have solved the problem. I add a sentence in the code.
polyline.spatialReference = new SpatialReference(102113);


It seems to add the spatial reference. And the value,102113 is important!
Thanks!

View solution in original post

0 Kudos
3 Replies
DasaPaddock
Esri Regular Contributor
Can you use a tool like HttpFox to see what the response from the server is?
0 Kudos
sunjian
Emerging Contributor
Can you use a tool like HttpFox to see what the response from the server is?


I have solved the problem. I add a sentence in the code.
polyline.spatialReference = new SpatialReference(102113);


It seems to add the spatial reference. And the value,102113 is important!
Thanks!
0 Kudos
IvanBespalov
Frequent Contributor
WebMercatorUtil
Projects coordinates between   4326 (GCS_WGS_1984) and   102100/3857 (WGS_1984_Web_Mercator_Auxiliary_Sphere) coordinate systems. Useful when showing data defined in geographic coordinates on top of a Web Mercator based map.


and your polyline is in spatial reference with WKID=102113

:confused:
0 Kudos