Select to view content in your preferred language

Documentation that instructs how to create polylines through code, doesn't work

396
2
11-11-2022 08:54 AM
MoreInfoTheBetter
New Contributor

Hello, I followed the documentation instruction to create polylines through code, but it does not work. 

 

In the documentation, the snipped code offered is this one

"// define some map points (airports: LA, Chicago, Paris)
var laxPoint = new ArcGISPoint(-118.408, 33.943, ArcGISSpatialReferences.Wgs84);
var ordPoint = new ArcGISPoint(-87.905, 41.979, ArcGISSpatialReferences.Wgs84);
var orlyPoint = new ArcGISPoint(2.379, 48.723, ArcGISSpatialReferences.Wgs84);

// add the points to a collection
var stops = new ArcGISPoint[] { laxPoint, ordPoint, orlyPoint };

// create a new Polyline from the points
var myFlightPath = new Esri.GameEngine.Geometry.ArcGISPolyline(stops);"


Reasons for the problems that I'm having:
-> ArcGISSpatialReferences.Wgs84 -> ArcGISSpatialReferences don't exist the only thing close to this that works is this: ArcGISSpatialReference.WGS84()

-> Esri.GameEngine.Geometry.ArcGISPolyline(stops) -> This does not take parameters, so it does not work, and I have no idea what should be added to work. Could you please provide me what I might be missing and which documentation I can follow in order for this to work?

0 Kudos
2 Replies
Matt_Nelson
Esri Alum

ArcGISSpatialReference.WGS84() is the correct spatial reference method to use.

 

As for this line 

// create a new Polyline from the points
var myFlightPath = new Esri.GameEngine.Geometry.ArcGISPolyline(stops);"

 

You actually need to use the ArcGISPolylineBuilder class to create a polyline
It will look something like this 

var myFlightPath = new Esri.GameEngine.Geometry.ArcGISPolylineBuilder(stops.Length, ArcGISSpatialReference.WGS84());"

foreach (stop in stops)

myFlightPath.AddPoint(stop);

 

Sorry about that we will get the doc updated

0 Kudos
Matt_Nelson
Esri Alum

Sorry slightly wrong with the code I suggested

var myFlightPath = new Esri.GameEngine.Geometry.ArcGISPolylineBuilder(ArcGISSpatialReference.WGS84());
foreach (var stop in stops)
{
myFlightPath.AddPoint(stop);
}

0 Kudos