- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 geoxml3 以便能够解析 kml 层的数量。现在,由于某种原因,它仅适用于点,不适用于多边形 kml 文件。以下是我正在使用的代码;
function displayKml() {
geo = new geoXML3.parser({
map: map,
zoom: false,
singleInfoWindow: true,
infoWindowOptions: { maxWidth: 100 },
processStyles: true,
markerOptions: { shadow: '' }
});
geo.parse("Resources/" + document.getElementById('<%= text2.ClientID %>').value);
}
以下是多边形 kml 文件的片段;
<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document><Folder><name>polygon_road</name>
<Schema name="polygon_road" id="polygon_road">
<SimpleField name="Name" type="string"></SimpleField>
<SimpleField name="Description" type="string"></SimpleField>
<SimpleField name="id" type="int"></SimpleField>
<SimpleField name="road_id" type="int"></SimpleField>
</Schema>
<Placemark>
<Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>0</fill></PolyStyle></Style>
<ExtendedData><SchemaData schemaUrl="#polygon_road">
<SimpleData name="id">1</SimpleData>
<SimpleData name="road_id">8</SimpleData>
</SchemaData></ExtendedData>
<Polygon><outerBoundaryIs><LinearRing><coordinates>14.517292705321212,35.901268542738997 14.517607913551563,35.901660659810574 14.517685853364705,35.901598006913375 14.517365353364706,35.901199306913377 14.517359591135264,35.901193253552186 14.517352901130216,35.901188244530104 14.508563647353409,35.895689849334943 14.508510612009246,35.895774626998687 14.517292705321212,35.901268542738997</coordinates></LinearRing></outerBoundaryIs></Polygon>
</Placemark>
<Placemark>
<Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>0</fill></PolyStyle></Style>
<ExtendedData><SchemaData schemaUrl="#polygon_road">
<SimpleData name="id">2</SimpleData>
<SimpleData name="road_id">10</SimpleData>
</SchemaData></ExtendedData>
<Polygon><outerBoundaryIs><LinearRing><coordinates>14.518412050213227,35.900771848093811 14.518465407563996,35.900687272724355 14.510931707563996,35.895934372724355 14.510878350213227,35.896018948093811 14.518412050213227,35.900771848093811</coordinates></LinearRing></outerBoundaryIs></Polygon>
</Placemark>
<Placemark>
<Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>0</fill></PolyStyle></Style>
<ExtendedData><SchemaData schemaUrl="#polygon_road">
<SimpleData name="id">3</SimpleData>
<SimpleData name="road_id">12</SimpleData>
</SchemaData></ExtendedData>
<Polygon><outerBoundaryIs><LinearRing><coordinates>14.515100381551473,35.90111915074295 14.515153218448528,35.901034249257044 14.509212818448528,35.89733734925705 14.509159981551473,35.897422250742956 14.515100381551473,35.90111915074295</coordinates></LinearRing></outerBoundaryIs></Polygon>
</Placemark>
最佳答案
不要使用 geoxml3 的 trunk 版本它相当旧并且只支持标记。两者都是polys和 kmz分支支持多边形、折线和标记。如果不需要 zip 压缩(kmz 文件支持),请使用 polys 分支。如果您需要 KML 中更多符合标准的支持,kmz 分支可以更好地支持记录的标准,但没有针对非 kmz 文件进行良好的测试。
历史
trunk - (old, not currently maintained) original versionnetwork_link branch - (old, not currently maintained) development branch for network link functionality, not well testedpolys branch - development branch for polylines, polygons, current active development branch. Supports polylines, polygons, markers and groundoverlayskmz branch - development branch for kmz support, built off of the polys branch. Supports external styles, and is more standards compliant. See issue 53 for details (http://code.google.com/p/geoxml3/issues/detail?id=53) and current status.
您的 KML 缺少 <width>
<LineStyle>
的属性(property)所以多边形的边界没有宽度(所以你看不到它们)。 kmz 分支有一组更好的默认值。如果我添加宽度,您可以看到它们:
关于javascript - 使用geoxml3显示多边形kml文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15369102/
需要一张葡萄牙 map ,用户可以在点击时选择地区,我关注了this example和 this one .问题是我为每个要绘制为多边形的地区使用 KML 文件,而不是为所有地区多边形使用 KML。
旧帖子 How can I use parse and parseKmlString together?? I need show a map loading one KML file (I use
我是一名优秀的程序员,十分优秀!