如何在Google地图中添加徽标到版权? [英] How to add logo to copyrights in google maps?

查看:104
本文介绍了如何在Google地图中添加徽标到版权?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向Google地图应用添加新图层,并希望在那里添加新徽标。就像在这种情况下一样:





有没有一些干净的方法可以在google maps API中使用,比如使用 GCopyright 和<$ c Google Maps API v2中的$ c> GCopyrightCollection 类?或者在v3中缺少这个功能(与许多其他功能一样),我必须手动完成它? 在Google Maps API v3 ,没有版权API。请注意,在第2版中, GCopyright 用于添加文本版权信息,而不是徽标。

徽标到地图上,您必须创建一个自定义控件

创建徽标自定义控件:

 函数MyLogoControl(controlDiv ){
controlDiv.style.padding ='5px';
var logo = document.createElement('IMG');
logo.src ='img / my_logo.png';
logo.style.cursor ='指针';
controlDiv.appendChild(logo);

google.maps.event.addDomListener(logo,'click',function(){
window.location ='http://www.example.com';
});

将控制添加到地图:

  var logoControlDiv = document.createElement('DIV'); 
var logoControl = new MyLogoControl(logoControlDiv);
logoControlDiv.index = 0; //用于订购
map.controls [google.maps.ControlPosition.BOTTOM_LEFT] .push(logoControlDiv);

同样可以添加版权信息。但是,您不能修改默认版权,您必须将其添加到默认值旁边的某处。



如果要添加绑定到边界框的版权信息和/或缩放级别,您必须手动创建此类行为。


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

Is there some clean way how to do it in the google maps API, like using GCopyright and GCopyrightCollection classes in google maps API v2? Or is this missing in v3 (like many other features) and I have to do it manually?

解决方案

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.

这篇关于如何在Google地图中添加徽标到版权?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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