kmlレイヤーの数を解析できるようにするために、geoxml3を使用しています。何らかの理由で、ポイントに対してのみ機能し、ポリゴン 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>