Manually give a position to the Coordinate Conversion widget

300
2
Jump to solution
05-16-2023 02:38 PM
MaicollDavidArizaCoronado
New Contributor II

I am using the coordinateConversion widget and I need to give it a location manually. I have a button that does an external conversion to the widget and that conversion returns longitude and latitude. I need to send those coordinates to the widget to be able to visualize them but I have not been able to do it, what can I do in this case, is there any way to pass that position to the widget?
Thanks in advance

0 Kudos
2 Solutions

Accepted Solutions
JoelBennett
MVP Regular Contributor

This is done by setting the currentLocation property.  The documentation says that property is read-only, but that's incorrect.

function visualize(latitude, longitude, ccWidget) {
	ccWidget.currentLocation = Point.fromJSON({x:longitude,y:latitude,spatialReference:{wkid:4326}});
}

 

View solution in original post

MaicollDavidArizaCoronado
New Contributor II

Lo he conseguido tal cual instanciando un nuevo punto y asignandoselo a la propiedad de currentLocation

const point = new Point({
              latitude: decimalLatitude,
              longitude: -decimalLongitude
            });

coordinate_convers.currentLocation = point

 

View solution in original post

2 Replies
JoelBennett
MVP Regular Contributor

This is done by setting the currentLocation property.  The documentation says that property is read-only, but that's incorrect.

function visualize(latitude, longitude, ccWidget) {
	ccWidget.currentLocation = Point.fromJSON({x:longitude,y:latitude,spatialReference:{wkid:4326}});
}

 

MaicollDavidArizaCoronado
New Contributor II

Lo he conseguido tal cual instanciando un nuevo punto y asignandoselo a la propiedad de currentLocation

const point = new Point({
              latitude: decimalLatitude,
              longitude: -decimalLongitude
            });

coordinate_convers.currentLocation = point