How to add logo to copyrights in google maps?

前端 未结 1 772
故里飘歌
故里飘歌 2020-12-16 08:01

I\'m adding new layers to my google map application and want to add new logo there. Like in this case:

\"enter

相关标签:
1条回答
  • 2020-12-16 08:27

    In Google Maps API v3, there's no copyright API. Note that in v2, the GCopyright was used to add textual copyright information, not a logo.

    To add a logo to the map you have to create a custom control.

    Create a logo custom control:

    function MyLogoControl(controlDiv) {
        controlDiv.style.padding = '5px';
        var logo = document.createElement('IMG');
        logo.src = 'img/my_logo.png';
        logo.style.cursor = 'pointer';
        controlDiv.appendChild(logo);
    
        google.maps.event.addDomListener(logo, 'click', function() {
            window.location = 'http://www.example.com'; 
        });
    }
    

    Add the control to the map:

    var logoControlDiv = document.createElement('DIV');
    var logoControl = new MyLogoControl(logoControlDiv);
    logoControlDiv.index = 0; // used for ordering
    map.controls[google.maps.ControlPosition.BOTTOM_LEFT].push(logoControlDiv);
    

    Similarly a copyright information can be added. But you can't modify the default copyrights, you have to add yours somewhere next to the defaults.

    If you want to add a copyright information that's bound to a bounding box and/or zoom level, you have to create such behaviour manually.

    0 讨论(0)
提交回复
热议问题