在Google地图上显示消息

时间:2012-05-29 14:10:48

标签: google-maps openlayers

我在我的学术项目中使用Google地图,从几周开始,每当我在地图上执行某些操作(如放大,缩小)时,地图上都会显示一条消息。可能是什么原因?我需要配置吗?我代码中的任何内容。enter image description here

您可以在上面的图片中看到该消息,消息标题为'Map Data'。我们在项目中使用开放层图,编码语言是PHP。

1 个答案:

答案 0 :(得分:1)

我在这里读到,一个原因可能是某些元素掩盖了地图数据的版权,但我发现有一些关于同一通知的投诉突然出现而没有提到这一点。

我找到的最有希望的选项是a page saying the solution is to upgrade to 2.12,或者如果你不能,那么在包含OpenLayers.js之后应用补丁

<script src="http://maps.google.com/maps/api/js?v=3.5&amp;sensor=false"></script>
    <script src="../lib/OpenLayers.js"></script>
    <script>
    OpenLayers.Layer.Google.v3.repositionMapElements = function() {
        // This is the first time any Google layer in this mapObject has been
        // made visible.  The mapObject needs to know the container size.
        google.maps.event.trigger(this.mapObject, "resize");

        var div = this.mapObject.getDiv().firstChild;
        if (!div || div.childNodes.length < 3) {
            this.repositionTimer = window.setTimeout(
                OpenLayers.Function.bind(this.repositionMapElements, this),
                250
            );
            return false;
        }

        var cache = OpenLayers.Layer.Google.cache[this.map.id];
        var container = this.map.viewPortDiv;

        // move the ToS and branding stuff up to the container div
        // depends on value of zIndex, which is not robust
        for (var i=div.children.length-1; i>=0; --i) {
            if (div.children[i].style.zIndex == 1000001) {
                var termsOfUse = div.children[i];
                container.appendChild(termsOfUse);
                termsOfUse.style.zIndex = "1100";
                termsOfUse.style.bottom = "";
                termsOfUse.className = "olLayerGoogleCopyright olLayerGoogleV3";
                termsOfUse.style.display = "";
                cache.termsOfUse = termsOfUse;
            }
            if (div.children[i].style.zIndex == 1000000) {
                var poweredBy = div.children[i];
                container.appendChild(poweredBy);
                poweredBy.style.zIndex = "1100";
                poweredBy.style.bottom = "";
                poweredBy.className = "olLayerGooglePoweredBy olLayerGoogleV3 gmnoprint";
                poweredBy.style.display = "";
                cache.poweredBy = poweredBy;
            }
            if (div.children[i].style.zIndex == 10000002) {
                container.appendChild(div.children[i]);
            }
        }

        this.setGMapVisibility(this.visibility);
    };
    </script>
    <script src="google-v3.js"></script>