jgpacker / osm-smart-menu

An OpenStreetMap webextension for Firefox and Chrome
GNU General Public License v3.0
56 stars 12 forks source link

Respect Google zoom level when translating to OSM #137

Open jidanni opened 3 years ago

jidanni commented 3 years ago

https://www.google.com.tw/maps/@24.1199229,120.6795117,262m/data=!3m1!1e3 is a highly zoomed in Google map. Alas, this translates to a very zoomed out https://www.openstreetmap.org/?mlat=24.1199229&mlon=120.6795117#map=12/24.1199/120.6795

Therefore a smarter algorithm of reverse engineering the Google zoom level is needed.

tankaru commented 3 years ago

Hi,

My app converts "262m" to ZOOM with this formula,

HEIGHT=262;
ZOOM = Math.round(-1.44 * Math.log(HEIGHT) + 26.9);

And if you tilt satellite map, parameters are changed like this. https://www.google.com.tw/maps/@24.116981,120.6793821,267a,35y,2.91h,50.83t/data=!3m1!1e3

In this case "267a" can be converted to ZOOM. I use this formula.

HEIGHT2 = 267;
ZOOM = Math.round(-1.44 * Math.log(HEIGHT2) + 27.5);

These formulas are approximations. Not precise.

jidanni commented 1 year ago

All I know is today I am looking at https://goo.gl/maps/zsA3mfueLaUPtiRC8 and I end up at https://www.openstreetmap.org/?mlat=42.0750527&mlon=-87.805818#map=12/42.0751/-87.8058 . Seen on chrome desktop.