跳至主要內容
Cartograph Maps

圖資包

圖資包是 ZIP 檔案,可用來輕鬆安裝自訂地圖、樣式、高程資料及其他資料。圖資包由一組檔案和一個名為 mapdetails.json 的指示檔組成。您可以在這裡下載範例圖資包,或在這裡安裝。

只要以下列格式建立連結,就能輕鬆從您的伺服器安裝圖資包:「cartograph://www.myserver.com/mymappackage.cpkg」。

圖資包可以包含:


建立「mapdetails.json」檔案

「mapdetails.json」是一個 JSON 檔案,其中包含告訴 Cartograph 應用程式要安裝哪些檔案的指示。建議使用 Visual Studio Code(免費,macOS、Windows)或 Notepad++(免費,僅限 Windows)來建立及編輯這個檔案。打包之前,建議先檢查檔案是否有錯誤,例如將內容複製到這個網站:「http://json.parser.online.fr/」。

以下程式碼是一個完整的範例檔案,所有元素將在後面說明。

{
  "version": 3,
  "extracted_size_mb": 116,
  "elevationdata": [
    "*.hgt"
  ],
  "maps": [
    {
      "type_hint": "folder",
      "name": "Sample folder",
      "uniqueId": "folder_abc",
      "folder_key":""
    },
    {
      "type_hint": "mapsforge",
      "name": "Sample A",
      "file": "sampleA.map",
      "load_in_layer": -1,
      "uniqueId": "mapA",
      "folder_key":"folder_abc"
    }
  ],
  "styles": [
    {
      "type_hint": "folder",
      "name": "Sample folder",
      "uniqueId": "folder_abc",
      "folder_key":""
    },
    {
      "type_hint": "mapsforge",
      "file": "samplestyle.zip",
      "load_in_layer": 0,
      "uniqueId": "abc",
      "folder_key":"folder_abc"
    }
  ],
  "overlays": [
    {
      "type_hint": "folder",
      "name": "Sample folder",
      "uniqueId": "folder_abc",
      "folder_key":""
    },
    {
      "type_hint": "mapsforge",
      "name": "Huts and shelters",
      "file": "sampleA.poi",
      "load": true,
      "uniqueId": "abc1",
      "folder_key":"folder_abc"
    }
  ],
  "routingaudio": [
    {
      "name": "Test audio package 1",
      "folder": "testaudio"
    }
  ],
  "commands": [
    {
      "command": "mapposition",
      "lat": 28.61,
      "lon": -15.5,
      "zoom": 10
    },
    {
      "command": "preimportmessage",
      "title": {
        "default": "Information"
      },
      "message": {
        "default": "The Sample Map package will now be installed. This can take several minutes.",
        "de": "Das Sample Kartenpaket wird jetzt installiert."
      }
    },
    {
      "command": "postimportmessage",
      "title": {
        "default": "Success",
        "de": "Erfolg"
      },
      "message": {
        "default": "The Sample Map package has been installed.",
        "de": "Das Sample Kartenpaket wurde installiert."
      }
    },
    {
      "command": "openwebsiteafterinstallation",
      "url": "http://www.cartograph.eu"
    }
  ]
}

中繼資料

"version": 3,
"extracted_size_mb": 116

中繼資料描述圖資包的一般資訊。version 一律應為「3」。extracted_size_mb 應大致等於圖資包中所有檔案的總大小。


高程資料

"elevationdata": [
  "*.hgt",
  "N12W13.hgt"
]

elevationdata 包含高程資料檔案的清單。可以是單一檔案(例如「N12W13.hgt」),也可以是圖資包中某種類型的所有檔案(例如「*.hgt」)。


BRouter 路線規劃資料

"routingdata": [
  "*.rd5",
  "E10_N45.rd5"
]

routingdata 包含用於離線路線規劃的 BRouter 區段檔案(.rd5)清單。與高程資料一樣,可以列出單一檔案(例如「E10_N45.rd5」)或圖資包中所有的 .rd5 檔案(「*.rd5」)。應用程式會將它們安裝到 BRouter 區段資料夾中,並取代同名的區段檔案。

安裝檔案之前,應用程式會檢查:

  • 檔案名稱:必須是 BRouter 區段名稱,例如「E10_N45.rd5」或「W5_S10.rd5」。其他檔案會被略過。
  • lookup 版本:區段檔案必須是以與應用程式路線規劃設定檔相同的 BRouter lookup 版本建立。其他版本的檔案會被略過,因為 BRouter 會在沒有任何提示的情況下忽略它。

略過的檔案會列在安裝完成後顯示的報告中;圖資包的其餘內容仍會照常安裝。


資料夾

{
  "type_hint": "folder",
  "name": "Sample folder",
  "uniqueId": "folder_abc",
  "folder_key":""
}

地圖、樣式和圖層都可以用資料夾分組。資料夾以 “type_hint”: “folder” 項目定義。uniqueId 必須是資料夾的唯一識別碼。重複使用同一個 uniqueId 可能導致非預期的行為。建議的 uniqueId 格式為「com.myserver.some_unique_id」。folder_key 包含上層資料夾的 uniqueId,可用來建立多層資料夾。若 folder_key 留空,資料夾會建立在根資料夾中。


地圖

  "maps": [
    {
      "type_hint": "folder",
      "name": "Sample folder",
      "uniqueId": "folder_abc",
      "folder_key":""
    },
    {
      "type_hint": "mapsforge",
      "name": "Sample A",
      "file": "sampleA.map",
      "load_in_layer": -1,
      "uniqueId": "mapA",
      "folder_key":"folder_abc"
    }
  ]

maps 元素包含資料夾與地圖的清單。type_hint 欄位提供說明地圖類型的提示:

  • 「mapsforge」:Mapsforge 地圖。
  • 「mapsforge_raster」:Mapsforge 點陣地圖。
  • 「mbtiles_raster」:MBTiles SQLite 點陣地圖。
  • 「mbtiles_mvt_vector」:MBTiles SQLite 向量地圖。
  • 「locus_sqlite」:Locus SQLite 地圖。
  • 「rmap」:TwoNav RMAP 點陣地圖。
  • 「map」:其他所有地圖類型。
  • 「garmin_img」:Garmin IMG 地圖。
  • 「garmin_gmap」:(以 ZIP 壓縮的)Garmin GMAP。

選用的 name 欄位可設定地圖在應用程式中顯示的名稱(例如「德國 – 中部」,而不是檔案名稱)。若省略、留空或與「file」相同,地圖會以其檔案名稱命名。

load_in_layer 欄位表示安裝圖資包後是否自動載入地圖。大於「-1」的值會將地圖載入該圖層(取代原本顯示在那裡的地圖);「-1」則只匯入地圖。

地圖也可以選擇設定縮放限制:

    {
      "type_hint": "mapsforge",
      "name": "Sample A",
      "file": "sampleA.map",
      "min_zoom": 8,
      "max_zoom": 18,
      "default_zoom": 12
    }

min_zoom 和 max_zoom 設定顯示地圖的縮放範圍;limit_zoom(true 或 false,預設為 true)用來開啟或關閉這項限制。省略某個值,就會保留地圖本身的限制。default_zoom 設定地圖的預設縮放(地圖屬性中的「預設縮放」);省略則保留地圖本身的設定。


樣式

  "styles": [
    {
      "type_hint": "folder",
      "name": "Sample folder",
      "uniqueId": "folder_abc",
      "folder_key":""
    },
    {
      "type_hint": "mapsforge",
      "file": "samplestyle.zip",
      "load_in_layer": 0,
      "uniqueId": "abc",
      "folder_key":"folder_abc"
    }
  ]

styles 元素包含資料夾與樣式的清單。type_hint 欄位提供說明樣式類型的提示:

  • 「mapsforge」:Mapsforge 樣式(算圖主題)。

load_in_layer 欄位表示安裝圖資包後,是否自動將該樣式載入為預設樣式。大於「-1」的值會將該樣式載入為預設樣式。


圖層

  "overlays": [
    {
      "type_hint": "folder",
      "name": "Sample folder",
      "uniqueId": "folder_abc",
      "folder_key":""
    },
    {
      "type_hint": "mapsforge",
      "name": "Huts and shelters",
      "file": "sampleA.poi",
      "load": true,
      "uniqueId": "abc1",
      "folder_key":"folder_abc"
    }
  ]

overlays 元素包含資料夾與圖層的清單。type_hint 欄位提供說明圖層類型的提示:

  • 「mapsforge」:Mapsforge POI 圖層。

load 欄位表示安裝圖資包後是否自動載入圖層。值為「true」表示會自動載入圖層。

選用的 name 欄位可設定圖層在應用程式中顯示的名稱。若省略或留空,圖層會以其檔案名稱命名。


路線規劃音訊檔案

  "routingaudio": [
    {
      "name": "Test audio package 1",
      "folder": "testaudio"
    }
  ]

routingaudio 元素包含路線規劃音訊檔案的資訊。詳細說明請參閱音訊包頁面。


指令

  "commands": [
    {
      "command": "mapposition",
      "lat": 28.61,
      "lon": -15.5,
      "zoom": 10
    },
    {
      "command": "preimportmessage",
      "title": {
        "default": "Information"
      },
      "message": {
        "default": "The Sample Map package will now be installed. This can take several minutes.",
        "de": "Das Sample Kartenpaket wird jetzt installiert."
      }
    },
    {
      "command": "postimportmessage",
      "title": {
        "default": "Success",
        "de": "Erfolg"
      },
      "message": {
        "default": "The Sample Map package has been installed.",
        "de": "Das Sample Kartenpaket wurde installiert."
      }
    },
    {
      "command": "openwebsiteafterinstallation",
      "url": "http://www.cartograph.eu"
    }
  ]

commands 元素可讓您在安裝圖資包之前和之後執行特定動作。以下各節將詳細說明每個指令。


地圖位置

{
  "command": "mapposition",
  "lat": 28.61,
  "lon": -15.5,
  "zoom": 10
}

mapposition 元素會在安裝後將地圖移到這個位置。


安裝前的訊息

{
  "command": "preimportmessage",
  "title": {
    "default": "Information"
  },
  "message": {
    "default": "The Sample Map package will now be installed. This can take several minutes.",
    "de": "Das Sample Kartenpaket wird jetzt installiert."
  }
}

preimportmessage 會在安裝圖資包之前顯示含「確定」與「取消」的訊息對話框。如果選擇「取消」,就不會安裝圖資包。


安裝後的訊息

{
  "command": "postimportmessage",
  "title": {
    "default": "Success",
    "de": "Erfolg"
  },
  "message": {
    "default": "The Sample Map package has been installed.",
    "de": "Das Sample Kartenpaket wurde installiert."
  }
}

postimportmessage 會在安裝圖資包之後顯示訊息對話框。


開啟網站網址

{
  "command": "openwebsiteafterinstallation",
  "url": "http://www.cartograph.eu"
}

openwebsiteafterinstallation 會在安裝圖資包之後開啟網站。


加入離線高程地圖

{
  "command": "addofflinemap",
  "type": "offline_slope",
  "load_in_layer": 1
}

addofflinemap 指令會加入一張應用程式從高程資料計算出的地圖,例如使用同一個圖資包中的高程資料。type 可以是「offline_hgt」(地形陰影)、「offline_slope」(坡度圖)或「offline_relief」(地勢圖);load_in_layer 的用法與地圖相同(「-1」= 加入地圖但不載入)。

選用的縮放鍵 limit_zoom、min_zoom、max_zoom 和 default_zoom 的用法與地圖相同:

{
  "command": "addofflinemap",
  "type": "offline_hgt",
  "limit_zoom": true,
  "min_zoom": 8,
  "max_zoom": 22,
  "default_zoom": 8,
  "load_in_layer": 4
}

每種類型的離線地圖在應用程式中只有一張。如果已經存在,圖資包中的縮放值會取代原本的設定。


直接在 Cartograph 應用程式中建立圖資包

您可以直接在 Cartograph 應用程式中,以現有的地圖、圖層、樣式、高程資料、BRouter 路線規劃資料(*.rd5)及路線規劃音訊檔案建立圖資包:位於主選單的工具窗格(建立圖資包,請參閱工具)。