Javascript 在GE插件中使用NetworkLinkControl进行更新时出现问题
我使用KML加载图像覆盖,然后尝试使用NetworkLinkControl更改摄影机视图值,例如高度。GE插件中未反映我的NetworkLinkControl更新。我在这个问题上做了很多研究,但都没有结果。任何帮助都将不胜感激 详情如下: 该过程从加载NetworkLink KML文件开始:Javascript 在GE插件中使用NetworkLinkControl进行更新时出现问题,javascript,kml,google-earth-plugin,Javascript,Kml,Google Earth Plugin,我使用KML加载图像覆盖,然后尝试使用NetworkLinkControl更改摄影机视图值,例如高度。GE插件中未反映我的NetworkLinkControl更新。我在这个问题上做了很多研究,但都没有结果。任何帮助都将不胜感激 详情如下: 该过程从加载NetworkLink KML文件开始: google.earth.fetchKml(ge, href, function(kmlObject) { ... 其中的.appendChild()如下所示: walkKmlDom(kmlOb
google.earth.fetchKml(ge, href, function(kmlObject) { ...
其中的.appendChild()
如下所示:
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:
<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&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>
服务器用KML 4响应(在服务器日志中指示):
照片
1.
http://hostname/images/ge_icon.png
$[说明]
http://hostname/images/10000244.kml?auth_key=e34962fce2df4829b0e86870c9e834da&nodesc=1
55
这应该是可行的,因为:
设置了onChange
,并且networkLinkControl.getLink().setHref()
正在进行更改
正确定位KML 2中的
针对的是KML 1中正确的
工作方法?如果您有任何想法,我们将不胜感激。尝试将相机元素本身作为目标,而不是照片覆盖父对象。当您试图在目标父级的基础上进行几级更改时,Google Earth中的KML更新就无法正常工作 换言之,我会尝试以下方法: KML 1
我的照片
-122.668
45.5069
1
66
90
0
然后在网络链接更新中:
<NetworkLinkControl>
<Update>
<targetHref>http://hostname/images/10000244.kml?auth_key=e34962fce2df4829b0e86870c9e834da&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>
http://hostname/images/10000244.kml?auth_key=e34962fce2df4829b0e86870c9e834da&nodesc=1
55
一般来说,最好以要更改的简单元素的直接父元素为目标。层叠更新的效果不太好
我还建议您在Google Earth本身的纯KML中尝试一下,看看它是否有效。然后,在执行NLC更新后,您可以复制PhotoOverlay并将代码粘贴到编辑器中,然后查看更改是否正确应用
让我知道这是否有效…尝试将相机元素本身作为目标,而不是PhotoOverlay父对象。当您试图在目标父级的基础上进行几级更改时,Google Earth中的KML更新就无法正常工作 换言之,我会尝试以下方法: KML 1
我的照片
-122.668
45.5069
1
66
90
0
然后在网络链接更新中:
<NetworkLinkControl>
<Update>
<targetHref>http://hostname/images/10000244.kml?auth_key=e34962fce2df4829b0e86870c9e834da&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>
http://hostname/images/10000244.kml?auth_key=e34962fce2df4829b0e86870c9e834da&nodesc=1
55
一般来说,最好以要更改的简单元素的直接父元素为目标。层叠更新的效果不太好
我还建议您在Google Earth本身的纯KML中尝试一下,看看它是否有效。然后,在执行NLC更新后,您可以复制PhotoOverlay并将代码粘贴到编辑器中,然后查看更改是否正确应用
让我知道这是否有效
var updateHref='http://http://hostname/netlinkcontrol/10000244?&altitude=55&auth_key=e34962fce2df4829b0e86870c9e834da'
networkLinkControl.getLink().setHref(updateHref);
<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&nodesc=1</targetHref>
<Change>
<PhotoOverlay targetId="image_10000244">
<Camera>
<altitude>55</altitude>
</Camera>
<ViewVolume></ViewVolume>
<Point></Point>
</PhotoOverlay>
</Change>
</Update>
</NetworkLinkControl>
</Document>
</kml>
<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>
<NetworkLinkControl>
<Update>
<targetHref>http://hostname/images/10000244.kml?auth_key=e34962fce2df4829b0e86870c9e834da&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>