Hi all,
I want to get screenPoints of polyline (maybe array of points, no problem). For point features i use code:
projection.load().then(function () {
let screenPoint = view.toScreen(feature.geometry);console.log(screenPoint.x, screenPoint.y);
}
A polyLine is just a series of points inside a 'paths' array.You can just use a javascript .forEach() to go through each point in the array create a new Point from the coordinates and to output the screenPoint.Note polyLines can have multiple line segments so you'll want to check each line segment as well.//pseduoCode exampleconst polyLine = feature.geometry // Your polyLine feature. polyLine.paths.forEach((path) => { //for each line segment inside your polyLinepath.forEach((coordinates) => { //for each coordinate in your line segmentconst newPoint = new Point(...) //create a new Point using the path coordinateslet screenPoint = view.toScreen(newPoint );console.log(screenPoint.x, screenPoint.y);})})
Hi @JamesIng, thank you. your answer is what i was looking for
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.