How to make zoomToBoundingBox like android osm
I want to zoom the map with existing markers (minLat, minLng, maxLat, maxLng). Is there any way to initialize MapViewPosition with bounding paramaters.
Interesting problem. The position is easy. It is the center of the bounding box.
With the help of PixelProjection.latLonToPixel() you could calculate the absolute pixels for the left-upper and right-bottom bounding box. So you know how many pixels must be visible in the view.
ViewModel.mapDimension gives you the current width/height of the view or determine it by yourself e.g. with LayoutBuilder.
scaleFactor can be calculated then by dividing the necessary mappixels by the available screenpixels.
Since the scaleFactor is a function of 2^zoomLevel (see ScaleFactor.dart) with a little play-around you should be able to calculate the correct zoomLevel.
I would be happy if you create a PullRequest with this new feature so that it is availabe to others too.
Thank you Mike, I will be busy next week on this calculation in my local. I will inform you.
PixelProjection constructor needs PixelProjection(int zoomLevel, this.tileSize) what's the correct init values. BTW, I found left-upper and right bottom coordinates but couldn't calculate the mappixels with Mappoint values.