calculateScale method
Implementation
double calculateScale(Size? containerSize) {
if (containerSize == null) {
return 1.0;
}
Size? newContainerSize;
double newWidth = 0, newHeight = 0;
if (containerSize.aspectRatio < 1 && mapSize.aspectRatio > 1) {
newWidth = containerSize.width;
newHeight = newWidth * containerSize.width / containerSize.height;
newContainerSize = Size(newWidth, newHeight);
return newContainerSize.width / mapSize.width;
}
if (containerSize.aspectRatio < 1 && mapSize.aspectRatio < 1) {
newHeight = containerSize.height;
newWidth = newHeight * (mapSize.aspectRatio);
newContainerSize = Size(newWidth, newHeight);
return newContainerSize.height / mapSize.height;
}
newContainerSize = Size(newWidth, newHeight);
// Scale for Responsive UI
double scale1 = newContainerSize.width / mapSize.width;
double scale2 = newContainerSize.height / mapSize.height;
double mapScale = scale1 > scale2 ? scale1 : scale2;
return mapScale;
}