2

Is there a way to determine static Google map's zoom level which Google sets it by default for best fit.

I want to display the static map with selected zoom level in select option box.

For ex: For below Static Map, Google has chosen zoom level of 15.

https://maps.googleapis.com/maps/api/staticmap?key=AIzaSyDl_HSyk4C2MdhzNIur6fMj-jhRTTVjd58&size=490x640&maptype=roadmap&markers=scale:2|12.10626240,-68.93910320&markers=scale:2|12.10555400,-68.93314500&markers=scale:2|12.10509740,-68.93377480&markers=scale:2|12.10573060,-68.94097440&markers=scale:2|12.10701300,-68.93240400&markers=scale:2|12.12509600,-68.92307300&markers=scale:2|12.10557200,-68.93322700&markers=scale:2|12.10327700,-68.92828200&markers=scale:2|12.10326160,-68.92827090&markers=scale:2|12.10990400,-68.93834300&markers=scale:2|12.10573200,-68.93849500&markers=scale:2|12.10849100,-68.93637800&markers=scale:2|12.10688160,-68.93691380&scale=2&style=feature:all

One possible way is to draw a dynamic Google map and find its zoom level using JavaScript. But I want to avoid this as it takes little time to load the page.

Is this possible using the static map API or any other alternative to achieve the same?

I am using PHP and JavaScript for this project.

Any help is very much appreciated!

1 Answer 1

1

Solution: Zoom Level Google Maps Static API

To set up a custom zoom level, one needs to just add a "zoom" parameter to the request you are making. Thus, if your desired Zoom Level is say, "13"..

The URL

Does this answer the question?

Sign up to request clarification or add additional context in comments.

2 Comments

zoom parameter can be used to set zoom level. But, I need to get Google's default zoom level so that i can set it into a select option box.
The Static Maps API states, "Normally, you need to specify center and zoom URL parameters to define the location and zoom level of your generated map. However, if you supply markers, path, or visible parameters, you can instead let the Google Static Maps API determine the correct center and zoom level implicitly, based on evaluation of the position of these elements." I checked up the response headers but they do not provide any info about the zoom level that is being set automatically. You could always set it to a particular(default) zoom level and change accordingly.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.