toOffset method

Offset toOffset(
  1. LatLng location
)

Converts LatLng coordinates to XY Offset.

Implementation

Offset toOffset(LatLng location) {
  final scale = pow(2.0, controller.zoom);

  final norm = controller.projection.toTileIndex(controller.center);

  final l = controller.projection.toTileIndex(location);

  final dx = l.x - norm.x;
  final dy = l.y - norm.y;

  final s = tileSize * scale;

  return Offset(_centerX + dx * s, _centerY + dy * s);
}