voll
voll

Reputation: 305

How to change Google logo's href

I would like to change the “Click to see this area on Google Maps” link, but I can't select the proper a tag.

Thanks

Upvotes: 0

Views: 361

Answers (2)

voll
voll

Reputation: 305

I noted that changing the href is not desirable because every time the map is dragged or zoomed in/out, the href is set to a new value. So setting an event, as suggested in davcs86's answer, is the best approach.

Here is the code:

$(document).on("mousedown", "a[href$='mapclient=apiv3']", function(){
  $(this).attr("href", "http://NEW-URL-YOU-WANT");
});

I used onmousedown instead of onclick because it responds to the middle button.

Upvotes: 0

davcs86
davcs86

Reputation: 3935

You can take advantage of RobH's answer

var anchors = document.getElementsByTagName('a'),
    l = anchors.length,
    i,
    a;

for (i = 0; i < l; i++) {
    a = anchors[i];
    if (a.href.indexOf('maps.google.com/maps?') !== -1) {
         // here you can manipulate the anchor
         a.title = ''; 
         a.onclick = function () { return false; };
    }
}

NOTE

Remember It's against the Google Maps API ToS to remove the Google branding or the ToS link.

Upvotes: 1

Related Questions