How to calculate zoom URL parameter at the Google Maps Preview (new version GM)?

此生再无相见时 提交于 2019-12-21 05:03:30

问题


I need to write chrome extension which references on new version of Google Maps site.

BUT, in new google maps preview i can not give link becouse i can't calculate new zoom parameter.

For example, URL new google maps: https://www.google.com/maps/preview#!data=!1m4!1m3!1d4112402!2d-62.7728736!3d44.829016

new zoom parameter are very strange:

zoom 23 http://google.com/maps/preview#!data=!1m4!1m3!1d 1145       !2d29.6765085!3d59.868445
...
zoom 12 http://google.com/maps/preview#!data=!1m4!1m3!1d 77910      !2d29.6765085!3d59.868445
zoom 11 http://google.com/maps/preview#!data=!1m4!1m3!1d 155852     !2d29.6765085!3d59.868445
zoom 10 http://google.com/maps/preview#!data=!1m4!1m3!1d 311710     !2d29.6765085!3d59.868445
zoom 9  http://google.com/maps/preview#!data=!1m4!1m3!1d 623333     !2d29.568544!3d59.8698115
zoom 8  http://google.com/maps/preview#!data=!1m4!1m3!1d 1247028    !2d29.568544!3d59.8698115
zoom 7  http://google.com/maps/preview#!data=!1m4!1m3!1d 2493322    !2d29.568544!3d59.8698115
zoom 6  http://google.com/maps/preview#!data=!1m4!1m3!1d 4987951    !2d29.568544!3d59.8698115
zoom 5  http://google.com/maps/preview#!data=!1m4!1m3!1d 9979726    !2d29.568544!3d59.8698115
zoom 4  http://google.com/maps/preview#!data=!1m4!1m3!1d 19959453   !2d29.568544!3d59.8698115
zoom 3  http://google.com/maps/preview#!data=!1m4!1m3!1d 40027823   !2d29.568544!3d52.0636483
zoom 2  http://google.com/maps/preview#!data=!1m4!1m3!1d 80266577   !2d29.568544!3d48.7705008
zoom 1  http://google.com/maps/preview#!data=!1m4!1m3!1d 100000000  !2d29.568544!3d47.3841015
     ↑                                                       ↑           ↑            ↑     
old google                                      new zoom parameter      LAT         LONG
maps zoom                                       on Google Maps Preview
parameter                                       depends on coordinates
intuitive and easy                              how to calculate it?

This parameter depends on coordinates!

How can i generate link on new google maps with this zoom, if i know old zoom parameter (from 1 to 23)?

I think I need a new weird setting for a new function Globe... but i don't know how to compute this... google search don't know answer

If zoom parameter is bad - maps redirect to home location.


回答1:


How about using the alternative @ syntax when linking to the maps?

Template:

https://www.google.co.uk/maps/place/@{LATITUDE},{LONGITUDE},{ZOOM}z

Example:

https://www.google.co.uk/maps/place/@29.6765085,59.868445,12z https://www.google.co.uk/maps/place/@29.6765085,59.868445,11z



来源:https://stackoverflow.com/questions/18582066/how-to-calculate-zoom-url-parameter-at-the-google-maps-preview-new-version-gm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!