I've got 2 GeoPoints given to show them on the map with markers.
How can I get the optimum zoom level for the MapController in order to focus the middle of both points, but also have them on the map.
The whole thing should work at different screen resolutions.
You can change the zoom level of the map using simple steps. Step 1 Go to Add or Edit Map page . Step 2 Select 'Default zoom level' in the 'Map Information section'. Step 3 click save map and see the changes.
Users can zoom the map by clicking the zoom controls. They can also zoom and pan by using two-finger movements on the map for touchscreen devices.
To fix Google maps zooming problems, for Google maps default zoom you want to know how to change the zoom level on Google Maps. You can change the zoom level by going to the Edit map page and then selecting 'default zoom level' in the map information section and then clicking save map.
You can do this using the MapView's MapController. You get the MapController using MapView.getController(), then you can attempt to set the correct zoom using MapController.zoomToSpan(). I also tend to use ItemizedOverlay's getLatSpanE6() and getLonSpanE6() to make this simpler. An example:
MapView map = (MapView) findViewById(R.id.Map);
MapController mc = map.getController();
mc.zoomToSpan(overlay.getLatSpanE6(), overlay.getLonSpanE6());
It is important to note their caveat:
Because the zoom can only achieve discrete levels, and because the aspect ratio of the map may not match the ratio given, the quality of the fit may vary. The only thing we guarantee is that, after the zoom, at least one of the new latitude or the new longitude will be within a factor of 2 from the corresponding parameter.
Edit: In order to also get the map to zoom on the correct place, you have to use MapController.setCenter().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With