getScreenCoordinate method

  1. @override
Future<ScreenCoordinate> getScreenCoordinate(
  1. LatLng latLng, {
  2. required int mapId,
})
override

Return ScreenCoordinate of the LatLng in the current map view.

A projection is used to translate between on screen location and geographic coordinates. Screen location is in screen pixels (not display pixels) with respect to the top left corner of the map, not necessarily of the whole screen.

Implementation

@override
Future<ScreenCoordinate> getScreenCoordinate(
  LatLng latLng, {
  required int mapId,
}) async {
  final Map<String, int> point = (await channel(mapId)
      .invokeMapMethod<String, int>(
          'map#getScreenCoordinate', latLng.toJson()))!;

  return ScreenCoordinate(x: point['x']!, y: point['y']!);
}