0
我正在使用公共api作爲本地交通系統的應用程序。這個應用程序的一部分涉及使用地圖api在地圖上繪製特定公交路線的路徑。Android谷歌地圖api只顯示kml文件的一部分
這是很容易的KML層添加到地圖上,像這樣:
KmlLayer layer = new KmlLayer(map, resId, getActivity().getApplicationContext());
layer.addLayerToMap();
的問題是,我給出的KML數據在一個大文件〜100條路線。
這裏的文件看起來像一個非常小樣本:
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<Placemark>
<ExtendedData>
<Data name="route_number">
<value>67</value>
</Data>
<Data name="direction">
<value>0</value>
</Data>
<Data name="route_description">
<value>Bethany/158th</value>
</Data>
<Data name="public_route_number">
<value>67</value>
</Data>
<Data name="direction_description">
<value>To PCC Rock Creek</value>
</Data>
<Data name="frequent">
<value>False</value>
</Data>
<Data name="type">
<value>BUS</value>
</Data>
</ExtendedData>
<MultiGeometry>
<LineString>
<coordinates>-122.858564,45.566031 -122.858623,45.566074 -122.858682,45.566096 -122.858754,45.566103 -122.858829,45.566096 -122.859393,45.565952</coordinates>
</LineString>
<LineString>
<coordinates>-122.859215,45.563005 -122.859429,45.563006 -122.859430,45.563086 -122.859418,45.563214 -122.859404,45.563267 </coordinates>
</LineString>
</MultiGeometry>
</Placemark>
<Placemark>
<ExtendedData>
<Data name="route_number">
<value>67</value>
</Data>
<Data name="direction">
<value>1</value>
</Data>
<Data name="route_description">
<value>Bethany/158th</value>
</Data>
<Data name="public_route_number">
<value>67</value>
</Data>
<Data name="direction_description">
<value>To Merlo Rd/158th Ave</value>
</Data>
<Data name="frequent">
<value>False</value>
</Data>
<Data name="type">
<value>BUS</value>
</Data>
</ExtendedData>
<MultiGeometry>
<LineString>
<coordinates>-122.859393,45.565952 -122.859394,45.565951 -122.859515,45.565912 -122.859605,45.565868 -122.859664,45.565818 -122.859721,45.565759 -122.859753,45.565709 -122.859786,45.565640 -122.859814,45.565569 -122.859710,45.565552 -122.859617,45.565533 </coordinates>
</LineString>
</MultiGeometry>
</Placemark>
</Document>
</kml>
實際上,每個路線是KML文件中不同的地標。我想每次只能通過路線編號訪問一個地標。
我不知道如何去從kml文件中只提取一個地標並將其顯示在地圖上。
任何想法? 謝謝!