What would be the best way to limit the number of decimals in coordinates shown in the CoordinateConversion widget.
I can achieve this by building my own Formats, but is it possible to use the existing format definitions?
I am not sure if this is optimal, but I solved it like this:
const coordConversion = new CoordinateConversion({ view, id: 'coordinate-container', storageType: 'local', visibleElements: { settingsButton: false, } }); // <a href="https://community.esri.com/t5/user/viewprofilepage/user-id/69004">@ts</a>-ignore: The JS API can autocast this coordConversion.conversions = ["mgrs"]; const toRemove = coordConversion.formats.filter(format => format.name == "basemap" || format.name == "usng"); coordConversion.formats.removeMany(toRemove); // Format "dd" to 3 decimals const ddFormat = coordConversion.formats.find(format => format.name == "dd"); ddFormat.conversionInfo = { convert: function (point) { const returnPoint = point.spatialReference.isWGS84 ? point : webMercatorUtils.webMercatorToGeographic(point) as Point; const formattedCoordinates = coordinateFormatter.toLatitudeLongitude(returnPoint, "dd", 3); return { location: point, coordinate: formattedCoordinates }; } }; view.ui.add(coordConversion, 'bottom-left');
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.