2013-03-16 71 views
0

我希望能夠使用geoxml3將圖層疊加到地圖上。我一直在努力嘗試去理解可能會出錯的地方,因爲它對於點來說工作得很好,但是當涉及到多邊形和線串時,它什麼也不顯示。雖然看起來正在通過geoxml3解析器,因爲縮放正在根據數據進行調整,但沒有任何內容會顯示。使用geoxml3解析

所有這三個版本的geoxml3我都試過了,結果都一樣。

以下是我的linestring kml文件。請注意,該文件在Google地圖和Google地球上運行良好。

<?xml version="1.0" encoding="utf-8"?> 
<kml xmlns="http://www.opengis.net/kml/2.2"> 
    <Document> 
    <Name>route</Name> 
    <Placemark> 
     <Style> 
     <LineStyle> 
      <color>ff0000ff</color> 
     </LineStyle> 
     </Style> 
     <LineString> 
     <coordinates>14.5077989214673,35.8935010311257 14.5077613878199,35.8935045284545 14.5077103878199,35.8935219284544 14.5076594878199,35.8935697284545 14.5076594878199,35.8935697284545 14.506821184327,35.894410303289 14.5066562791164,35.8947140342037 </coordinates> 
     </LineString> 
    </Placemark> 
    </Document> 
</kml> 

以下是處理解析的javascript方法。

function displayKml() { 
    geo = new geoXML3.parser({ 
     map: map, 
     zoom: true, 
     singleInfoWindow: true   
    }); 
    geo.parse("Uploads/" + document.getElementById('<%= text2.ClientID %>').value); 
} 

任何幫助表示讚賞,因爲我已經三天了試圖找出它。

回答

1

<LineString>在您的KML不具有寬度

<Style> 
    <LineStyle> 
     <color>ff0000ff</color> 
    </LineStyle> 
    </Style> 

地址:

<Style> 
    <LineStyle> 
     <width>1</width> 
     <color>ff0000ff</color> 
    </LineStyle> 
    </Style> 

geoxml3的多邊形分支目前沒有對寬度的默認值(所以它是零,這意味着你看不到它):

多分支無寬度: http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.html?filename=http://www.geocodezip.com/geoxml3_test/SO_IT_info_kmlB.xml

與寬度的多邊形分支: http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.html?filename=http://www.geocodezip.com/geoxml3_test/SO_IT_info_kmlC.xml

geoxml3的KMZ分公司確實有寬度的默認情況下,應該有工作:

KMZ分支與你原來的KML: http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmztest_linktoB.html?filename=http://www.geocodezip.com/geoxml3_test/SO_IT_info_kmlB.xml

Opened an issue against geoxml3

修復了這個問題(所以上面的例子工作,不再顯示問題)

+0

我認爲問題是另一回事,因爲地圖正在放大,而線條應該出現在地圖上,但仍然沒有顯示。我真的不知道是什麼問題。 @geocodezip – 2013-03-16 18:06:52

+0

geoxml3的poly分支正在用我的KML做上述例子,直到我移植了從kmz分支處理的「默認樣式」。他們現在都爲我的KML工作(kmz分支總是爲我的KML工作)。 – geocodezip 2013-03-16 19:43:11

+0

它適用於您發佈的代碼 - [示例](http://www.geocodezip.com/geoxml3_test//v3_simpleMap_geoxml3.html) – geocodezip 2013-03-16 22:10:46