谷歌地图链接来自滑油键默认缩放 [英] Google maps link from greasemonkey default zoom

查看:74
本文介绍了谷歌地图链接来自滑油键默认缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近在Google地图上发生了某些更改,从而更改了默认缩放比例.我尝试添加zoom = 17和z = 17,但似乎没有什么改变.

Something seems to have changed on google maps recently that changed the default zoom. I've tried adding zoom=17 and z=17, but nothing seems to change.

我只是使用以下url&在页面上创建超链接.查询

I'm just creating a hyperlink on page using the following url & query

" https://maps.google.com/?zoom=17&q= " + myAddress.replace(//g,'+');

"https://maps.google.com/?zoom=17&q=" +myAddress.replace(/ /g, '+');

过去,无论我在查询中使用什么地址,它始终可以正常工作.只是想知道可能会发生什么变化,以及是否需要以其他方式解决这个问题.

In the past it's always worked fine no matter what address I used in the query. Just wondering what may have changed and if I need to work around this another way.

推荐答案

这就是我最终用来解决该问题的方法.如布罗克所说,我可以指定纬度和经度以z = 16缩放.

Here's what I ended up using to solve the problem. I can specify zoom by z=16 provided latitude and longitude as Brock explained.

addMapLL('900+w+900+s+clearfield+UT');  // just a random address formatted

function addMapLL(address) {
    var api = "https://maps.googleapis.com/maps/api/geocode/json?sensor=true&address=" + address;

     GM_xmlhttpRequest(
    {
        method: 'GET',
        url: api,
        onload: function(resp) {
            var obj = JSON.parse(resp.responseText);

            if (obj.status == "OK") {
                var lat = obj.results[0].geometry.location.lat;
                var lng = obj.results[0].geometry.location.lng;
                var ll  = "&ll=" + lat + "," + lng;

                // .href is already set as follows
                // https://maps.google.com/?z=16&q=900+w+900+s+clearfield+UT
                document.getElementById('googlemap').href += ll;
            }
        }
    });
}

这篇关于谷歌地图链接来自滑油键默认缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆