【问题标题】:Use JavaScript inside balloons in the Google Earth client在 Google 地球客户端的气球内使用 JavaScript
【发布时间】:2017-01-06 22:41:06
【问题描述】:

I've found a resource suggesting there is a method do this,但是引用的链接会引发 google 代码错误。有人有在气球中使用 javascript 的例子吗?

我做了几个例子:

<Placemark>
    <name>Object</name>
    <description><![CDATA[<br><br><br>
        <input value="Test" onchange="this.value=this.value.toUpperCase()">
    ]]></description>
<gx:balloonVisibility>1</gx:balloonVisibility>
    <Polygon>
        <extrude>1</extrude>
        <tessellate>1</tessellate>
        <outerBoundaryIs>
            <LinearRing>
                <coordinates>
                    -1.278059,53.020596,0 -1.278079,53.02062700000001,0 -1.278115,53.02065200000001,0 -1.278164,53.020667,0 -1.278219,53.02067,0 -1.278272,53.020662,0 -1.278316,53.020642,0 -1.278345,53.02061400000001,0 -1.278356,53.020582,0 -1.278346,53.020549,0 -1.278318,53.020521,0 -1.278274,53.020501,0 -1.278222,53.020491,0 -1.278167,53.020494,0 -1.278118,53.020508,0 -1.27808,53.020533,0 -1.27806,53.020563,0 -1.278059,53.020596,0 
                </coordinates>
            </LinearRing>
        </outerBoundaryIs>
    </Polygon>
</Placemark>

但是,我能够制作的示例都不是非常复杂的。而且我也不知道如何“探索”它……因为没有开发者工具……

【问题讨论】:

    标签: kml google-earth


    【解决方案1】:

    我在这里找到了一些信息: JavaScript In KML Ignored By Google Earth Plugin

    代码:

    <?xml version="1.0" encoding="UTF-8"?>
    <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
        <Folder>
            <name>South Florida</name>
            <open>1</open>
            <Document>
                <name>Miami</name>
                <Style id="miami_style">
                    <IconStyle>
                        <Icon>
                            <href>http://i.imgur.com/CNrRU.gif</href>
                        </Icon>
                    </IconStyle>
                    <BalloonStyle>
                        <text><![CDATA[<font face="Arial">$[description]</font>]]></text>
                    </BalloonStyle>
                </Style>
                <Folder>
                    <name>Miami</name>
                    <open>1</open>
                    <Placemark id="Miami">
                        <name>Miami</name>
                        <description><![CDATA[
                            <script type="text/javascript">
                                function hideImage() {
                                    var image = document.getElementById("image");
                                    image.style.opacity = 0;
                                    image.style.MozOpacity = 0;
                                    image.style.KhtmlOpacity = 0;
                                    image.filter = "alpha(opacity=0)";
                                }
                            </script>
                            <button id='clicker' onclick='hideImage();'>Click Me</button>
                            <img id="image" src="http://i.imgur.com/4rhT7.png">
                        ]]></description>
                        <styleUrl>#miami_style</styleUrl>
                        <Point>
                            <coordinates>-80.22643611111111,25.788952777777777,0</coordinates>
                        </Point>
                    </Placemark>
                </Folder>
            </Document>
        </Folder>
    </kml>
    

    最终它是标准的 HTML。不过也有限制。

    • alert() 不起作用 - 所有消息都必须写入元素。
    • VBS 和其他脚本语言不起作用。 (因为它不是IE控件)
    • 它的范围非常有限 - 它看不到相邻的地标/与之交互。
    • 无法获取窗口对象
    • 似乎无法创建 objectURLs

    【讨论】:

      猜你喜欢
      • 2012-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多