2011-07-05 22 views
3

我一直在尋找相當長一段時間沒有成功的問題的答案。 所以這裏它去...KMLViewer蘋果的例子不起作用

KMLViewer,Apple的例子在某些情況下不起作用。 執行README步驟後,我試圖在葡京葡京和葡萄牙波爾圖之間建立一條路線。這裏發生了最奇怪的事情。雖然覆蓋(MKPolyline)沒有,但它只繪製部分路線,並開始在「註釋」的中間進行繪製。

我在想什麼? 你可以試試,馬德里 - 巴塞羅那,你也有同樣的問題。

提前感謝您花時間在這個問題上。

回答

2

看起來像KMLViewer每Placemark只能處理一個LineString對象。

對於您嘗試的路線,Google將在「路線」地標(文件中的最後一個)中返回兩個LineString對象。 KMLViewer僅顯示第二個(最後一個)LineString段。

除了更新KMLViewer代碼中添加每標(它看起來像一個很好的鍛鍊)的多個線段形式對象的支持,你可以嘗試以下兩種解決方法:

從兩個LineString的對象組合的座標轉換成一個線段形式。變化:

<Placemark> 
    <name>Route</name> 
    <description>some cdata stuff here</description> 
    <GeometryCollection> 
     <LineString><coordinates>coord1 … coordN</coordinates></LineString> 
     <LineString><coordinates>coordN+1 … coordK</coordinates></LineString> 
    </GeometryCollection> 
    <styleUrl>#roadStyle</styleUrl> 
</Placemark> 

要這樣:

<Placemark> 
    <name>Route</name> 
    <description>some cdata stuff here</description> 
    <GeometryCollection> 
     <LineString><coordinates>coord1 … coordN coordN+1 … coordK</coordinates></LineString> 
    </GeometryCollection> 
    <styleUrl>#roadStyle</styleUrl> 
</Placemark> 

以上可能只會令對於被認爲是連續的路徑(線段)感。

另一個解決辦法是「途徑」標分成多個地標(每個線段形式):

<Placemark> 
    <name>Route A</name> 
    <description>some cdata stuff here</description> 
    <GeometryCollection> 
     <LineString><coordinates>coord1 … coordN</coordinates></LineString> 
    </GeometryCollection> 
    <styleUrl>#roadStyle</styleUrl> 
</Placemark> 
<Placemark> 
    <name>Route B</name> 
    <description>some cdata stuff here</description> 
    <GeometryCollection> 
     <LineString><coordinates>coordN+1 … coordK</coordinates></LineString> 
    </GeometryCollection> 
    <styleUrl>#roadStyle</styleUrl> 
</Placemark> 

一個與此問題是,「說明」,其中包含了距離和時間信息不匹配分裂的路線。

+0

Thx爲您的答案,這是一個很好的幫助! – aGit

1

是。非常感謝您的快速響應。我在早上發現的問題是,這些標籤一起(接近&開放)

</coordinates></LineString><LineString><coordinates> 

我的計劃:

保存從URL輸出到的NSString,如果去掉上面存在的標籤,之後保存到一個文件併發送給KMLParser。 當我完成時,我會回來。

再次非常感謝您的回覆。

+0

我用這種方式解決了它,如果你需要更多的幫助來理解我所做的,只需要PM我:) – aGit