使用NetworkLinkControl进行GE插件更新时出现问题 [英] Issue using NetworkLinkControl for updates in GE plugin

查看:90
本文介绍了使用NetworkLinkControl进行GE插件更新时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用KML加载图像叠加层,然后尝试使用NetworkLinkControl更改相机视图值,例如海拔高度. GE插件中没有我的NetworkLinkControl更新.我对此问题做了很多研究,但没有成功.任何帮助将不胜感激.

I'm using KML to load an image overlay, and then I'm trying to change camera view values such as altitude using NetworkLinkControl. None of my NetworkLinkControl updates are reflected in the GE plugin. I've done quite a bit of research on this issue to no avail. Any help would be appreciated.

以下是详细信息:

该过程从加载NetworkLink KML文件开始:

The process starts with loading a NetworkLink KML file:

google.earth.fetchKml(ge, href, function(kmlObject) { ... 

在其中完成.appendChild()的方法如下:

inside which the .appendChild() is done like this:

    walkKmlDom(kmlObject, function() {
        if(this.getType().match('KmlNetworkLink')) {
            ge.getFeatures().appendChild(this);

            //There are 2 NetworkLinks
            if(this.getLink().getHref().match('nodesc')) {
                networkLinkPhoto = this;
            }
            else if(this.getLink().getHref().match('control')){
                networkLinkControl = this; //will use this for updates later
            }
        }
    });

上面的.fetchKml()加载以下KML 1:

The .fetchKml() above loads the following KML 1:

    <kml xmlns="http://www.opengis.net/kml/2.2">
        <Document>
            <name>Photos</name>
            <open>1</open>
            <Style id="photoStyle">
                <IconStyle>
                    <Icon>
                        <href>http://hostname/images/ge_icon.png</href>
                    </Icon>
                </IconStyle>
                <BalloonStyle>
                    <text>$[description]</text>
                </BalloonStyle>
            </Style>
            <Folder>
                <name>My Photo</name>
                <open>1</open>
                <visibility>1</visibility>
                <NetworkLink>
                    <name>My Photo</name>
                    <open>1</open>
                    <Link>
                        <href>http://hostname/images/10000244.kml?auth_key=e34962fce2df4829b0e86870c9e834da&amp;nodesc=1</href>
                    </Link>
                </NetworkLink>
                <NetworkLink>
                    <name>Updater</name>
                    <Link>
                        <href>http://hostname/placements/10000244/control?auth_key=e34962fce2df4829b0e86870c9e834da</href>
                        <refreshMode>onChange</refreshMode>
                    </Link>
                </NetworkLink>
            </Folder>
        </Document>
    </kml>

两个NetworkLink的每一个都通过<Link>中定义的URL加载自己的KML文件.

Each of the two NetworkLink loads it's own KML file through URLs defined in <Link>.

第一个是我的照片"(重叠)KML 2:

First one is My Photo (overlay) KML 2:

    <kml xmlns="http://www.opengis.net/kml/2.2">
        <Document>
            <name>Photos</name>
            <open>1</open>
            <Style id="photoStyle">
                <IconStyle>
                    <Icon>
                        <href>http://hostname/images/ge_icon.png</href>
                    </Icon>
                </IconStyle>
                <BalloonStyle>
                    <text>$[description]</text>
                </BalloonStyle>
            </Style>
            <PhotoOverlay id="image_10000244">
                <name>My Photo</name>
                <Snippet maxLines="1">
                    <![CDATA[<a href="#image_10000244">Enter Photo</a>]]>
                </Snippet>
                <Camera>
                    <longitude>-122.668</longitude>
                    <latitude>45.5069</latitude>
                    <altitude>1.0</altitude>
                    <heading>66.0</heading>
                    <tilt>90.0</tilt>
                    <roll>0.0</roll>
                </Camera>
                <styleUrl>#photoStyle</styleUrl>
                <color>feffffff</color>
                <Icon>
                    <href>http://hostname/get_ge_tile/10000244/$[level]/$[y]/$[x]?auth_key=e34962fce2df4829b0e86870c9e834da</href>
                </Icon>
                <rotation>0.0</rotation>
                <ViewVolume>
                    <leftFov>-17.5</leftFov>
                    <rightFov>17.5</rightFov>
                    <bottomFov>0.0</bottomFov>
                    <topFov>17.5</topFov>
                    <near>550.0</near>
                </ViewVolume>
                <ImagePyramid>
                    <tileSize>256</tileSize>
                    <maxWidth>16000</maxWidth>
                    <maxHeight>8000</maxHeight>
                    <gridOrigin>upperLeft</gridOrigin>
                </ImagePyramid>
                <Point>
                    <coordinates>-122.668,45.5069</coordinates>
                </Point>
                <shape>sphere</shape>
            </PhotoOverlay>
        </Document>
    </kml>

第二个是Updater KML 3:

The second one is Updater KML 3:

    <kml xmlns="http://www.opengis.net/kml/2.2">
        <Document>
            <name>Photos</name>
            <open>1</open>
            <Style id="photoStyle">
                <IconStyle>
                    <Icon>
                        <href>http://hostname/images/ge_icon.png</href>
                    </Icon>
                </IconStyle>
                <BalloonStyle>
                    <text>$[description]</text>
                </BalloonStyle>
            </Style>
            <NetworkLinkControl>
                <Update>
                    <targetHref>http://hostname/images/10000244.kml?auth_key=e34962fce2df4829b0e86870c9e834da&amp;nodesc=1</targetHref>
                    <Change>
                        <PhotoOverlay targetId="image_10000244">

                            <Camera></Camera>
                            <ViewVolume></ViewVolume>
                            <Point></Point>
                        </PhotoOverlay>
                    </Change>
                </Update>
            </NetworkLinkControl>
        </Document>
    </kml>

GE插件现在已加载KML,地标放置在 指定的坐标,然后双击地标即可进入照片 查看模式.

The GE plugin now has the KMLs loaded, the placemark is placed at the specified coordinates, and double clicking the placemark enters the photo view mode.

要更改照片的高度,javascript API会请求更新:

To change the photo's altitude, javascript API requests the update:

var updateHref='http://http://hostname/netlinkcontrol/10000244?&altitude=55&auth_key=e34962fce2df4829b0e86870c9e834da'
networkLinkControl.getLink().setHref(updateHref);

服务器使用KML 4响应(在服务器日志中指示):

The server responds (indicated in server log) with KML 4:

    <kml xmlns="http://www.opengis.net/kml/2.2">
        <Document>
            <name>Photos</name>
            <open>1</open>
            <Style id="photoStyle">
                <IconStyle>
                    <Icon>
                        <href>http://hostname/images/ge_icon.png</href>
                    </Icon>
                </IconStyle>
                <BalloonStyle>
                    <text>$[description]</text>
                </BalloonStyle>
            </Style>
            <NetworkLinkControl>
                <Update>
                    <targetHref>http://hostname/images/10000244.kml?auth_key=e34962fce2df4829b0e86870c9e834da&amp;nodesc=1</targetHref>
                    <Change>
                        <PhotoOverlay targetId="image_10000244">

                            <Camera>

                                <altitude>55</altitude>
                            </Camera>
                            <ViewVolume></ViewVolume>
                            <Point></Point>
                        </PhotoOverlay>
                    </Change>
                </Update>
            </NetworkLinkControl>
        </Document>
    </kml>

这应该起作用,因为:

    在KML 1中为更新程序<NetworkLink>设置了
  1. <refreshMode>onChange</refreshMode>,并且networkLinkControl.getLink().setHref()正在进行更改.
  2. KML 4中的
  3. <PhotoOverlay targetId="image_10000244">正确定位了KML 2中的<PhotoOverlay id="image_10000244">
  4. KML 4中的
  5. <targetHref>针对KML 1中的正确<href>
  1. <refreshMode>onChange</refreshMode> is set for the Updater <NetworkLink> in KML 1, and networkLinkControl.getLink().setHref() is making the change.
  2. <PhotoOverlay targetId="image_10000244"> in KML 4 is correctly targeting <PhotoOverlay id="image_10000244"> in KML 2
  3. <targetHref> in KML 4 is targeting the correct <href> in KML 1

GE插件不显示海拔高度变化.我尝试改变 此值通过javascript API起作用.但是为什么KML不是 方法有效吗?任何想法将不胜感激.

GE plugin however doesn't display the altitude change. I've tried changing this value through javascript API, which works. But why isn't the KML method working? Any ideas would be appreciated.

推荐答案

尝试定位Camera元素本身,而不是PhotoOverlay父对象.当您尝试将更改从目标父级下移几级时,Google Earth中的KML更新似乎效果不佳.

Try targetting the Camera element itself, not the PhotoOverlay parent. KML Updates in Google Earth don't see to work so well when you are trying to make changes a couple levels down from the targeted parent.

换句话说,我会尝试这样做:

In other words, I would try this:

KML 1

<PhotoOverlay id="image_10000244">
  <name>My Photo</name>
  <Snippet maxLines="1">
      <![CDATA[<a href="#image_10000244">Enter Photo</a>]]>
  </Snippet>
  <Camera id="image_10000244_camera">
      <longitude>-122.668</longitude>
      <latitude>45.5069</latitude>
      <altitude>1.0</altitude>
      <heading>66.0</heading>
      <tilt>90.0</tilt>
      <roll>0.0</roll>
  </Camera>
  <ViewVolume id="image_10000244_viewvol" />
</PhotoOverlay>

,然后在您的网络链接中更新:

and then in your networklinkupdate:

<NetworkLinkControl>
  <Update>
    <targetHref>http://hostname/images/10000244.kml?auth_key=e34962fce2df4829b0e86870c9e834da&amp;nodesc=1</targetHref>
    <Change>
      <Camera targetId="image_10000244">
        <altitude>55</altitude>
      </Camera>
    </Change>
    <Change>
      <ViewVolume targetId="image_10000244_viewvol">
        <!-- new values -->
      </ViewVolume>
    </Change>
  </Update>
</NetworkLinkControl>

通常,最好将您要更改的简单元素的直接父对象作为目标.级联更新效果不佳.

In general, it's best to target the immediate parent of the simple element you want to change. Cascading updates don't work so well.

我还建议您在Google Earth本身的纯KML中尝试此操作,以查看其是否有效.然后,在执行NLC更新之后,您可以复制PhotoOverlay并将代码粘贴到编辑器中,以查看更改是否正确应用.

I would also recommend that you try this in pure KML in Google Earth itself to see if it works. Then, after the NLC update is performed, you can copy out the PhotoOverlay and paste the code into your editor and see if the change was applied correctly.

让我知道是否可行...

Let me know if that works...

这篇关于使用NetworkLinkControl进行GE插件更新时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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