2013-10-25 59 views
0

我有100個點,有存儲在我的本地驅動器上的每個點的照片。每個點都有擴展的數據,其中包括圖片名稱的根(蜂樹)在谷歌地球中使用本地圖像

我有我的設置引用使用此行:img src =「/ files/$ [geotourism_points/PIC_NAME] .png」 ,當我將它保存爲kml時,它會起作用。但是,當我將它保存爲.kmz時,它將忽略$ [geotourism_points /並且僅返回img src =「files/PIC_NAME] .png」

我試圖使用使用../files/image的相對路徑名。 png,/files/image.png,files/image.png(你使用哪一個?!!)

我仍然無法使它工作。我可以用這種方式將圖像插入到我的氣球中(本地文件)嗎,還是必須將這些圖像加載到服務器並使用URL引用它們?

在此先感謝您的幫助!

這裏是整個代碼:

<?xml version="1.0" encoding="UTF-8"?> 
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"> 
<Document> 
    <name>KmlFile</name> 
    <Schema name="geotourism_points" id="geotourism_points_schema"> 
     <SimpleField type="string" name="MO_REGIO_1"><displayName>&lt;b&gt;MO_REGIO_1&lt;/b&gt;</displayName> 
</SimpleField> 
     <SimpleField type="string" name="TYPE"><displayName>&lt;b&gt;TYPE&lt;/b&gt;</displayName> 
</SimpleField> 
     <SimpleField type="string" name="NOTES_1"><displayName>&lt;b&gt;NOTES_1&lt;/b&gt;</displayName> 
</SimpleField> 
     <SimpleField type="string" name="WEBSITE"><displayName>&lt;b&gt;WEBSITE&lt;/b&gt;</displayName> 
</SimpleField> 
     <SimpleField type="string" name="SITE_NAME"><displayName>&lt;b&gt;SITE_NAME&lt;/b&gt;</displayName> 
</SimpleField> 
     <SimpleField type="string" name="LINK_2"><displayName>&lt;b&gt;LINK_2&lt;/b&gt;</displayName> 
</SimpleField> 
     <SimpleField type="string" name="ADDRESS"><displayName>&lt;b&gt;ADDRESS&lt;/b&gt;</displayName> 
</SimpleField> 
     <SimpleField type="string" name="PHONE"><displayName>&lt;b&gt;PHONE&lt;/b&gt;</displayName> 
</SimpleField> 
     <SimpleField type="string" name="PIC_NAME"><displayName>&lt;b&gt;PIC_NAME&lt;/b&gt;</displayName> 
</SimpleField> 
     <SimpleField type="string" name="SOURCE_1"><displayName>&lt;b&gt;SOURCE_1&lt;/b&gt;</displayName> 
</SimpleField> 
     <SimpleField type="int" name="NATUR"><displayName>&lt;b&gt;NATUR&lt;/b&gt;</displayName> 
</SimpleField> 
     <SimpleField type="int" name="CULTU"><displayName>&lt;b&gt;CULTU&lt;/b&gt;</displayName> 
</SimpleField> 
     <SimpleField type="int" name="REC"><displayName>&lt;b&gt;REC&lt;/b&gt;</displayName> 
</SimpleField> 
     <SimpleField type="int" name="ARCHEO"><displayName>&lt;b&gt;ARCHEO&lt;/b&gt;</displayName> 
</SimpleField> 
     <SimpleField type="int" name="HIST"><displayName>&lt;b&gt;HIST&lt;/b&gt;</displayName> 
</SimpleField> 
     <SimpleField type="double" name="OBJECTID"><displayName>&lt;b&gt;OBJECTID&lt;/b&gt;</displayName> 
</SimpleField> 
    </Schema> 
    <StyleMap id="pointStyleMap"> 
     <Pair> 
      <key>normal</key> 
      <styleUrl>#normPointStyle</styleUrl> 
     </Pair> 
     <Pair> 
      <key>highlight</key> 
      <styleUrl>#normPointStyle0</styleUrl> 
     </Pair> 
    </StyleMap> 
    <Style id="normPointStyle0"> 
     <IconStyle> 
      <Icon> 
       <href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png</href> 
      </Icon> 
     </IconStyle> 
     <BalloonStyle> 
      <text><![CDATA[<table width="350" cellpadding="1" cellspacing="0"> 
    <tr> 
    <td colspan="3" align="center" valign="top"> 
     <table border="0" width="100%" cellpadding="1" cellspacing="0"> 
     <tr> 
      <td align="left" valign="top"> 
      <img src="files/lecl_logo.png" alt="logo"/> 
      </td> 
      <td width="70%"" align="left" valign="bottom"> 
      <font color="#2f4f4f" size="+2"><strong>$[geotourism_points/SITE_NAME]</strong></font> 
      <br> 
      <font color="#999999"><em>$[geotourism_points/TYPE] </em></font> 
      <hr/> 
      </td> 
     </tr> 
     </table> 
    </td> 
    </tr> 
    <tr> 
    <td width="40%" align="left" valign="top"> 
     <p> 
     <br> 
     <font color="#666666"><strong>Visitor's Information:</strong></font> 
     <br><br> 
     <font color="#999999">$[geotourism_points/ADDRESS]<br>$[geotourism_points/PHONE]</font> 
     </p> 
     <p> 
     <a href="$[geotourism_points/WEBSITE]" target="_blank"><strong><em><font color="#2f4f4f">More Information...</font></strong></em></a> 
     </p> 
    </td> 
    <td align="left" valign="top"> 
     <table border="0" cellspacing="0" cellpadding="3" bgcolor="white"> 
     <tr> 
      <td align="center"><img src="files/$[geotourism_points/PIC_NAME].png" alt="picture" width="100%" align="left" valign="middle"/></td> 
     </tr> 
     <tr> 
      <td colspan="3" align="right"><font color="#999999" size="-1">$[geotourism_points/SOURCE_1]</font></td> 
     </tr> 
    </td> 
</table>]]></text> 
     </BalloonStyle> 
    </Style> 
    <Style id="normPointStyle"> 
     <IconStyle> 
      <Icon> 
       <href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png</href> 
      </Icon> 
     </IconStyle> 
     <BalloonStyle> 
      <text><![CDATA[<table width="350" cellpadding="1" cellspacing="0"> 
    <tr> 
    <td colspan="3" align="center" valign="top"> 
     <table border="0" width="100%" cellpadding="1" cellspacing="0"> 
     <tr> 
      <td align="left" valign="top"> 
      <img src="files/lecl_logo.png" alt="logo"/> 
      </td> 
      <td width="70%"" align="left" valign="bottom"> 
      <font color="#2f4f4f" size="+2"><strong>$[geotourism_points/SITE_NAME]</strong></font> 
      <br> 
      <font color="#999999"><em>$[geotourism_points/TYPE] </em></font> 
      <hr/> 
      </td> 
     </tr> 
     </table> 
    </td> 
    </tr> 
    <tr> 
    <td width="40%" align="left" valign="top"> 
     <p> 
     <br> 
     <font color="#666666"><strong>Visitor's Information:</strong></font> 
     <br><br> 
     <font color="#999999">$[geotourism_points/ADDRESS]<br>$[geotourism_points/PHONE]</font> 
     </p> 
     <p> 
     <a href="$[geotourism_points/WEBSITE]" target="_blank"><strong><em><font color="#2f4f4f">More Information...</font></strong></em></a> 
     </p> 
    </td> 
    <td align="left" valign="top"> 
     <table border="0" cellspacing="0" cellpadding="3" bgcolor="white"> 
     <tr> 
      <td align="center"><img src="files/$[geotourism_points/PIC_NAME].png" alt="picture" width="100%" align="left" valign="middle"/></td> 
     </tr> 
     <tr> 
      <td colspan="3" align="right"><font color="#999999" size="-1">$[geotourism_points/SOURCE_1]</font></td> 
     </tr> 
    </td> 
</table>]]></text> 
     </BalloonStyle> 
    </Style> 
    <Folder id="layer 0"> 
     <name>geotourism_points</name> 
     <open>1</open> 
     <Placemark> 
      <name>Bee Tree County Park</name> 
      <styleUrl>#pointStyleMap</styleUrl> 
      <ExtendedData> 
       <SchemaData schemaUrl="#geotourism_points_schema"> 
        <SimpleData name="MO_REGIO_1">Confluence Region</SimpleData> 
        <SimpleData name="TYPE">City/County Park</SimpleData> 
        <SimpleData name="NOTES_1">riverfront</SimpleData> 
        <SimpleData name="WEBSITE">stlouisco.com/ParksandRecreation/ParkPages/BeeTree</SimpleData> 
        <SimpleData name="SITE_NAME">Bee Tree County Park</SimpleData> 
        <SimpleData name="LINK_2"></SimpleData> 
        <SimpleData name="ADDRESS">2701 Finestown Road Saint Louis, MO 63129</SimpleData> 
        <SimpleData name="PHONE"></SimpleData> 
        <SimpleData name="PIC_NAME">bee-tree</SimpleData> 
        <SimpleData name="SOURCE_1">stlouisco.com</SimpleData> 
        <SimpleData name="NATUR">1</SimpleData> 
        <SimpleData name="CULTU">0</SimpleData> 
        <SimpleData name="REC">1</SimpleData> 
        <SimpleData name="ARCHEO">0</SimpleData> 
        <SimpleData name="HIST">0</SimpleData> 
        <SimpleData name="OBJECTID">234</SimpleData> 
       </SchemaData> 
      </ExtendedData> 
      <Point> 
       <coordinates>-90.32844745921075,38.40766261103909,0</coordinates> 
      </Point> 
     </Placemark> 
     <Placemark> 
      <name>Old St. Ferdinand Shrine</name> 
      <styleUrl>#pointStyleMap</styleUrl> 
      <ExtendedData> 
       <SchemaData schemaUrl="#geotourism_points_schema"> 
        <SimpleData name="MO_REGIO_1">Confluence Region</SimpleData> 
        <SimpleData name="TYPE">Historic Site</SimpleData> 
        <SimpleData name="NOTES_1"></SimpleData> 
        <SimpleData name="WEBSITE">http://www.oldstferdinandshrine.com/</SimpleData> 
        <SimpleData name="SITE_NAME">Old St. Ferdinand Shrine</SimpleData> 
        <SimpleData name="LINK_2"></SimpleData> 
        <SimpleData name="ADDRESS">#1 rue St. Francois, Florissant MO 63031</SimpleData> 
        <SimpleData name="PHONE">Phone: (314) 837-2110</SimpleData> 
        <SimpleData name="PIC_NAME">old-st-ferdinand-shrine</SimpleData> 
        <SimpleData name="SOURCE_1">viewfrombackpew.blogspot.com</SimpleData> 
        <SimpleData name="NATUR">0</SimpleData> 
        <SimpleData name="CULTU">0</SimpleData> 
        <SimpleData name="REC">0</SimpleData> 
        <SimpleData name="ARCHEO">0</SimpleData> 
        <SimpleData name="HIST">1</SimpleData> 
        <SimpleData name="OBJECTID">269</SimpleData> 
       </SchemaData> 
      </ExtendedData> 
      <Point> 
       <coordinates>-90.33389390094645,38.79675526749391,0</coordinates> 
      </Point> 
     </Placemark> 
    </Folder> 
</Document> 
</kml> 

回答

0

取決於你的目標受衆。是否想在互聯網或內部網站上共享KMZ和共享網絡驅動器上的照片等?

如果KMZ文件是本地文件,並且與KMZ文件相關的文件夾是「文件」(包括您的所有照片),那麼它將按原樣正確顯示在Google地球中。

如果您通過網站提供KMZ文件,並且這些文件是本地文件,那麼它將不起作用。如果使用相對鏈接,圖像必須與KML文件共存。

<img src="files/$[geotourism_points/PIC_NAME].png" alt="picture" .../> 

如果您在照片位置使用KML中的絕對URL,那麼KMZ將在您承載它的任何地方工作。

<img src="http://server/files/$[geotourism_points/PIC_NAME].png" alt="picture" .../> 

另一種方法是在KMZ中嵌入「文件」文件夾和照片,以便KML和照片是自包含的。然後,您可以在KML中使用相關鏈接。

+0

我將從一個網站分享KMZ。我以爲我通過將kml保存爲kmz來嵌入KMZ中的「files」文件夾。但它打破了實體替換/files/$[geotourism_points/PIC_NAME].png「並將其更改爲」files/PIC_NAME] .png「,因此找不到相對路徑。看起來最容易創建URL。感謝您的回覆! – user2918490

+0

爲什麼它會破壞路徑名?我找不到解決方法。我嘗試使用filezilla來提供圖像,但是這只是帶來了一大堆其他問題。 – user2918490

+0

嘗試使用src =「 ./files/...此外,將.kmz重命名爲.zip,然後將「files」文件夾添加爲zip文件,然後將其重命名爲.kmz。現在它工作? – JasonM1