pixelYToLatitude method
Converts a pixel Y coordinate to the corresponding latitude coordinate.
Uses inverse Mercator projection to calculate the geographic coordinate.
pixelY The pixel Y coordinate to convert
Returns the latitude in degrees
Implementation
double pixelYToLatitude(double pixelY) {
pixelY = min(max(0, pixelY), _mapSize.toDouble());
assert(pixelY >= 0, "pixelY ($pixelY) should be >= 0");
assert(pixelY <= _mapSize, "pixelY ($pixelY) should be <= mapSize ($_mapSize)");
const double pi2 = 2 * pi;
const double pi360 = 360 / pi;
double y = 0.5 - (pixelY / _mapSize);
return 90 - pi360 * atan(exp(-y * pi2));
}