开发者

Google Static Maps Panning and Zooming

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜