开发者

Google Static Maps Panning and Zooming

开发者 https://www.devze.com 2023-02-13 18:03 出处:网络
I\'ve got a scenario where I have a website that utilizes Google Maps, and falls back to Static Maps if the user doesn\'t have JavaScript.

I've got a scenario where I have a website that utilizes Google Maps, and falls back to Static Maps if the user doesn't have JavaScript.

A client requirement is that the user should still be able to pan and zoom (assuming a page refresh for each zoom, or pan).

So each zoom or pan, the page will refresh, and on the server side I need to regenerate a static map based upon what the user is trying to do.

The wa开发者_开发技巧y I'm initially generating the static map is passing in all of my markers (not defining a center point, or zoom, letting Google figure that out on their end) through the Google Static Maps URL.

The problem I'm running into is when I'm panning, how to get the bounds of the static map that Google generated, so I know what points to pan from.

Has anyone see this done? Or have any insight?

Programming language is Ruby.

Thanks!


I don't think it's possible (although I'd love for someone to prove me wrong) to easily get the bounds of a map from the Static Maps API.

Your best bet may be to calculate an appropriate center, zoom, and map size based on the markers you want to show rather than relying on Static Maps to do it for you, and then handle/calculate zooming and panning based on that.

0

精彩评论

暂无评论...
验证码 换一张
取 消