KML (Keyhole Markup Language),為 Google Earth或 Google Maps 用來呈現地理資料的一種 XML 語法,其所屬檔案附檔名為 KML。學習 kml 語法的好方式為開啟製作良好的 .kml or .kmz 檔案,選定想要學習的點、線或多邊形,在 Google 地圖該點上按滑鼠右鍵,選擇『複製』,開啟任何文字編輯器『貼上』即可。

Tag:

  • Style可以定義圖示型態,分別以icon, color, size定義其樣式、顏色、大小。在個別的聚落或事件可以直接引用。
  • TimeSpan:宣告一段時間,其起迄時間分別用begin和end這兩個tag來宣告。如果只有開始,沒有結束期,則只要宣告begin即可。
  • TimeStamp: 配合when宣告一個時間點。時間之宣告可以是「年」(2007)、「年-月」(2007-06),或「年-月-日」(2007-06-06)。注意:年要四位數,月、日均是二位數。
  • Placemark: GE 中最常使用的 tag,用以設定GE上單一點。A Point Placemark is the only way to draw an icon and label in the 3D Viewer of Google Earth. In KML, a <Placemark> can contain one or more geometry elements, such as a LineString, Polygon, or Model. But only a <Placemark> with a Point can have an icon and label.
    • A name that is used as the label for the Placemark
    • A description that appears in the “balloon” attached to the Placemark. If you want to write standard HTML inside a <description> tag, you can put it inside a CDATA tag.
    • A path is created by a <LineString> element. The <tessellate> tag breaks the line up into smaller chunks, and the <extrude> tag extends the line down to the ground.
    • You can use Polygons to create simple buildings and other shapes.
    • A Point that specifies the position of the Placemark on the Earth’s surface (longitude, latitude, and optional altitude)