我正在使用 KML 加载图像叠加层,然后尝试使用 NetworkLinkControl 更改相机视图值,例如高度。我的 NetworkLinkControl 更新都没有反映在 GE 插件中。我对这个问题做了很多研究,但无济于事。任何帮助,将不胜感激。
以下是详细信息:
该过程从加载 NetworkLink KML 文件开始:
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>
两个 NetworkLink 中的每一个都通过<Link>
.
第一个是我的照片(叠加)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>
第二个是更新程序 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&nodesc=1</targetHref>
<Change>
<PhotoOverlay targetId="image_10000244">
<Camera></Camera>
<ViewVolume></ViewVolume>
<Point></Point>
</PhotoOverlay>
</Change>
</Update>
</NetworkLinkControl>
</Document>
</kml>
GE 插件现在已加载 KML,地标放置在指定坐标处,双击地标进入照片查看模式。
要更改照片的高度,javascript API 请求更新:
var updateHref='http://http://hostname/netlinkcontrol/10000244?&altitude=55&auth_key=e34962fce2df4829b0e86870c9e834da'
networkLinkControl.getLink().setHref(updateHref);
服务器使用 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&nodesc=1</targetHref>
<Change>
<PhotoOverlay targetId="image_10000244">
<Camera>
<altitude>55</altitude>
</Camera>
<ViewVolume></ViewVolume>
<Point></Point>
</PhotoOverlay>
</Change>
</Update>
</NetworkLinkControl>
</Document>
</kml>
这应该有效,因为:
<refreshMode>onChange</refreshMode>
<NetworkLink>
为KML 1中的更新程序设置,并且networkLinkControl.getLink().setHref()
正在进行更改。<PhotoOverlay targetId="image_10000244">
在 KML 4 中正确定位<PhotoOverlay id="image_10000244">
在 KML 2<targetHref>
<href>
在 KML 4 中以 KML 1 中的正确为目标
但是 GE 插件不显示海拔变化。我尝试通过 javascript API 更改此值,该值有效。但为什么 KML 方法不起作用?任何想法,将不胜感激。