Google 地球 KML 无法正确渲染气球样式
这个问题已经困扰我大约两天了,谷歌没有帮助我解决这个问题。基本上,下面的代码应该定义气球内的文本。不幸的是,它不是这样工作的。如果 GE 无法处理 KML 中定义的样式,我们最终会采取后备措施。
以下是我尝试将 KML 直接注入 GE 插件进行渲染的一种(多种)方法。
var kmlString = '' +
'<?xml version="1.0" encoding="UTF-8"?>' +
'<kml xmlns="http://www.opengis.net/kml/2.2">' +
' <Document>' +
' <Style id="sitegeom">' +
' <BalloonStyle>' +
' <text>' +
' <![CDATA[' +
' this is<br>a test' +
' ]]>' +
' </text>' +
' </BalloonStyle>' +
' </Style>' +
' </Document>' +
'</kml>';
var kmlObject = $wnd.ge.parseKml(kmlString);
$wnd.ge.getFeatures().appendChild(kmlObject);
此代码片段所基于的代码直接来自 GE 文档。去算算吧。有人有主意吗?
This issue has been plaguing me for about 2 days Google isn't helping me figure this one out. Basically, the code below should be defining the text within the balloon. Unfortunately, it's not working that way. We're ending up with what seems to be the fallback if GE can't handle the style defined in the KML.
Here's one (of many) ways I've tried injecting the KML straight into the GE plugin for rendering.
var kmlString = '' +
'<?xml version="1.0" encoding="UTF-8"?>' +
'<kml xmlns="http://www.opengis.net/kml/2.2">' +
' <Document>' +
' <Style id="sitegeom">' +
' <BalloonStyle>' +
' <text>' +
' <![CDATA[' +
' this is<br>a test' +
' ]]>' +
' </text>' +
' </BalloonStyle>' +
' </Style>' +
' </Document>' +
'</kml>';
var kmlObject = $wnd.ge.parseKml(kmlString);
$wnd.ge.getFeatures().appendChild(kmlObject);
The code on which this snippet is based came directly from the GE docs. Go figure. Anyone have an idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您稍后添加的 KML 文档可能无法访问您在单独的 KML 文档中开始时定义的 #sitegeom ID,它不在范围内。
尝试按照 Google 地球文档有关此内容的说明,将样式定义在单独的文件中:
例如:
The KML document you're adding later likely can't access the #sitegeom ID you defined at the start in a separate KML document, it's not in-scope.
Try following the Google Earth doc instructions re: this, by placing the style definition in a separate file:
e.g.:
也许问题对我来说不太清楚,但我认为,您需要在 KML 中描述
Placemark
并在styleUrl
中定义您的样式就像这样:
这是正确的想法吗?
Maybe question not so clear for me, but i think, you need to describe
Placemark
in your KML and define your style instyleUrl
Like this:
Is it right idea?