I'm working in a Java Me application that uses google static maps. The problem is that I need to get the zoom and center that fits all markers, and I need to add some labels in some coordinates on the map. How can I do this? I need a function in the server or in the midlet to get this parameters, I can't use javascript.
I have had the same problem. Don't use "&zoom=xx" in your url, the map will auto-fit for all your markers!
You don't need to calculate it on your own.
When you supply markers, usually the map will have a viewport to show all markers.
To modify the viewport use the visible-parameter.
Referring to the comments:
Pseudo-Code for calculating the center from a couple of Points:
latitude: (maxLatOfAllPoints+minLatOfAllPoints)/2
longitude:(maxLngOfAllPoints+minLngOfAllPoints)/2
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