2011-11-17 144 views
1

我的谷歌地圖被配置以顯示藍色位置標記。谷歌地圖不顯示藍色位置標記(在Sitecore的網站時)

我的地圖中使用以下.KML文件(只是XML數據描述的地方顯示通過谷歌地圖API藍色位置標記),我與一個普通的老XMLHttpRequest對象加​​載。

我的問題是,當我從外部來源,如「http://xyz.com/kumedplaces.kml」加載.kml文件,它的工作原理,但是當我存儲它,並嘗試加載它從我的Sitecore的網站運行在本地服務器上,谷歌地圖對象不加載/顯示在地圖上的藍色位置標記。

下面是我在我的.js文件從做.KML文件加載地址後:

<div id="map" style="width: 400px; height: 300px"></div> 

    var kmlUrl = "http://xyz.com/kumedplaces.kml"; works 
    var kmlUrl = "/js/heart/kumedplaces.kml"; doesn't work 

    var geoXml = new GGeoXml(kmlUrl); 
    map.addOverlay(geoXml); 

和我做了我的地方,以確保我的本地.KML文件雙重檢查的方式被正確加載我.KML文件

樣品:

<?xml version="1.0" encoding="utf-8" ?> 
    <kml xmlns="http://earth.google.com/kml/2.1"> 
     <Document> 
     <name>University of Kansas Hospital Locations</name> 
     <description>The various buildings around the city that comprise the University of Kansas Hospital</description> 

    <Style id="randomColorIcon"> 
     <IconStyle> 
     <color>ff00ff00</color> 
     <colorMode>random</colorMode> 
     <scale>1.1</scale> 
     <Icon> 
      <href>http://maps.google.com/mapfiles/kml/pal3/icon21.png</href> 
     </Icon> 
     </IconStyle> 
    </Style> 

    <Placemark id="kumed"> 
     <name>The University of Kansas Hospital</name> 
     <description> 
     Part of the Kansas University Medical Center complex. 
     3901 Rainbow Blvd, Kansas City, KS 66160 
     </description> 
     <address>3901 Rainbow Blvd, Kansas City, KS 66160</address> 
     <phonenumber>xxxxxxx</phonenumber> 
     <ExtendedData></ExtendedData> 
     <!--<styleUrl>#randomColorIcon</styleUrl>--> 
     <Point> 
     <coordinates>-94.608800,39.0558241</coordinates> 
     </Point> 
    </Placemark> 
    </Document> 
</kml> 

回答

0

您需要正確的MIME類型添加到您的Web服務器來服務KML和KMZ文件。

對於kml - application/vnd.google-earth.kml+xml

對於kmz - application/vnd.google-earth.kmz

假設你正在使用IIS7,在IIS7經理下添加MIME類型這些。

0

KML文件需要公開訪問(因爲它們需要由Google服務器讀取),據我所知,您不能在本地引用KML文件(如Google不知道的那樣在哪裏尋找他們)。

相關問題