get a PolyLine path to go to center of screen

139
1
01-14-2020 01:02 PM
CamCode
New Contributor III

I am trying to draw a polyLine to the center of the screen (as the second path, point B) ... I tried referencing the below to get center: any pointers?

  coordinatesBx = map.extent.getCenter().getLatitude();  coordinatesBy = map.extent.getCenter().getLongitude();

The above errors with cannot getCenter() of undefined... should I try to get this in screenPoints first, then try to convert to lat long?

I am good with my first two start points as lat long coords, i.e. workingStartA and workingStartB; however I cannot get the second coordinatesBx and coordinatesBy to go to center of screen. I am in arcgis-JS 4.11 specifically.

i.e.

  var polyline = {      type: "polyline",      paths: [          [workingStartA, workingStartB],          [coordinatesBx, coordinatesBy]      ]  };
0 Kudos
1 Reply
KenBuja
MVP Honored Contributor

You are mixing up 3.x and 4.x syntax. Remember that in 4.x, a map doesn't have an extent (see Maps and Views in the documentation). Instead, you want to get the extent of the MapView. And the extent doesn't have a getCenter method. It has a center property, resulting in a Point that has a latitude and longitude property.