transformScreenToWgs method
Converts screen coordinates to WGS84 geographic coordinates.
Transforms a screen position in physical pixels to its corresponding geographic location on Earth (latitude, longitude, and optionally altitude). Screen coordinates are measured from the map view's top-left corner.
If the applied map style includes elevation data and terrain topography is loaded, the returned Coordinates include altitude information above sea level. Check terrain support using the hasTerrainTopography getter.
Parameters
screenCoordinates: Screen position in physical pixels, relative to the map view's top-left corner
Returns
- WGS84 coordinates (latitude, longitude, optional altitude) corresponding to the screen position
See also:
- transformWgsToScreen - Convert geographic coordinates to screen coordinates
- transformScreenToWgsRect - Convert screen rectangle to geographic area
- cursorWgsPosition - Get cursor position in geographic coordinates
Implementation
Coordinates transformScreenToWgs(final Point<int> screenCoordinates) {
final OperationResult resultString = objectMethod(
_pointerId,
'MapView',
'transformScreenToWgs',
args: XyType<int>.fromPoint(screenCoordinates),
);
final Coordinates coords = Coordinates.fromJson(resultString['result']);
if (coords.altitude != null &&
coords.altitude! > -0.0001 &&
coords.altitude! < 0.0001) {
coords.altitude = 0;
}
return coords;
}