1

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.

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

"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.

Cameron Darlington
  • 355
  • 2
  • 7
  • 14

3 Answers3

1

Google maps, now, will not zoom past z=13 unless Latitude and Longitude are also supplied. EG: &ll=98.414257,-21.727585.

As a scripter, this makes your task a bit more involved; here is a pseudocode approach that will work:

  1. Open the map page as before, but flag it (custom URL param or GM_setValue) as first opened by your script.

  2. Set the script to also run on Google maps pages.

  3. On flagged Google maps pages:

    1. Grab the share link.
    2. Change the z parameter only, EG &z=17.
    3. Make sure any flag is cleared.
    4. location.replace() to the modified share link


Alternatively, a more durable strategy is to switch to using the Google Maps API.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
  • Good to know. Where did you find the documentation explaining this? – Cameron Darlington Apr 05 '13 at 21:45
  • There is no (public) documentation for this. Several careful experiments showed the limits and proof-of-concept solution. – Brock Adams Apr 05 '13 at 22:05
  • Could I use the API to accomplish the same thing? I don't want to embed the map on my page. I would rather have it open in it's own window and still have all the same features as if I just searched for the address. – Cameron Darlington Apr 08 '13 at 17:38
  • The API works on embedded map objects. You *might* be able to hook into the same functions on the regular map page, but I don't use Google maps enough to know for sure. Poke around and see what's what. – Brock Adams Apr 08 '13 at 20:12
0

If you access Google Maps and click and share link button you will see something like this:

https://maps.google.com/?ll=53.944771,-0.854187&spn=0.890705,2.694397&t=m&z=9

So i think you should worry about some required field...

fernandosavio
  • 9,849
  • 4
  • 24
  • 34
0

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;
            }
        }
    });
}
Cameron Darlington
  • 355
  • 2
  • 7
  • 14