Hi everyone, I have a problem changing the coordinate type from the sketch feature to the XY coordinate type.
whenever i see result from draw coordinate type it stays basemap type.
code:
log:
please help me solve it.
Solved! Go to Solution.
Hi there,
Yes sketch creates geometries with a spatial reference that matches the spatial reference of the view. If your basemap's spatial reference is Web Mercator (102100) then you can use webMercatorUtils.webMercatorToGeographic() method to project the geometry to geographic spatial reference.
You can do something like the following.
sketch.on("create", (event) => {
if (event.state === "complete") {
console.log("sketch geometry", event.graphic.geometry);
const geographicGeom = webMercatorUtils.webMercatorToGeographic(event.graphic.geometry);
console.log("geographic geometry", geographicGeom)
}
});
If your basemap's spatialReference is not WebMercator then you can use projection.project() method.
Hope this helps,
Hi there,
Yes sketch creates geometries with a spatial reference that matches the spatial reference of the view. If your basemap's spatial reference is Web Mercator (102100) then you can use webMercatorUtils.webMercatorToGeographic() method to project the geometry to geographic spatial reference.
You can do something like the following.
sketch.on("create", (event) => {
if (event.state === "complete") {
console.log("sketch geometry", event.graphic.geometry);
const geographicGeom = webMercatorUtils.webMercatorToGeographic(event.graphic.geometry);
console.log("geographic geometry", geographicGeom)
}
});
If your basemap's spatialReference is not WebMercator then you can use projection.project() method.
Hope this helps,
Thanks. Its Worked
nice