I have a bit of code in a 3D SceneView for a draw-line tool that has worked fine until the 4.6 release. It basically grabs the map point when the user clicks on the map, and creates a line starting at that point, and adds each subsequently clicked point to the 'paths' property of the line until the user double clicks to end the process. The line is added to the map as a graphic.
After 4.6, however, I can't get the polyline.insertPoint() function to work, or any of the polyline functions for that matter. I threw together a jsbin that illustrates a similar problem: here. You have to open dev tools to see the results. I used the getPoint() function to keep it a bit simpler, but it throws an error that line.getPoint() is not a function (getPoint() documentation).
tldr: polyline.insertPoint(path index, point index, point) is not adding anything to the 'paths' property of the line I pass in
Any ideas whats going on here? Am I missing something?
Any help is much appreciated. Cheers
Andrew,
I think the place you were using the polyline before was autocasting. Your code in the JSBin is just creating a basic object and not a Polyline that is why the getPoint is not a function. You need to use new Polyline:
var testLine = new Polyline({
type: "polyline",
paths: [
[-0.178, 51.48791, 0],
[-0.178, 51.48791, 1000]
]
});
Thanks for replying Robert. The Jsbin I made uses autocasting because I grabbed it from some of ESRI's code samples, but I'm not actually using autocasting in my application. I create a true polyline and it still doesnt work. If I revert back to 4.5 it works fine, with no changes to the code, so it is definitely a 4.6 problem. the insertPoint() function just does not seem to be working from what I can tell. There are a couple of other problems I've noticed since switching to 4.6 too, so I'll be sticking with 4.5 until I can find a solution.
Cheers
Hi there,
I looked at the test application you had. As Robert pointed out you are using autocasted polyline. It won't work in this case because it is not `Polyline` object. So as he suggested you need to create a new instance of `Polyline` or you can directly work with the `Graphic.geometry`.
Here is a modified SDK sample that uses `getPoint ` and `inserPoint` methods on Polyline.
https://codepen.io/anon/pen/LeOYVZ?&editors=100
If you are still running into problems can you please give a snippet code that reproduces the issue you are running into?
Thank you
The underlying problem is that, for version 4.6, the insertPoint doesn't work when adding a point at the end of the ring. We plan to fix this for version 4.7. See also https://community.esri.com/thread/209499-polygon-and-polyline-insertpoint-function-seems-to-be-broke...