Google 地圖中的世界座標是從麥卡托投影的原點 (地圖的西北角,經度 180 度,緯度約 85 度) 開始測量;向東 (右) 增加 x 向度,向南 (下) 增加 y 向度。基本的麥卡托 Google 地圖圖塊是 256 x 256 像素,因此可用的世界座標空間是 {0-256}, {0-256}。
現在,我們可以在每個縮放等級下,精確表示地圖上的各個位置。Maps SDK for Android 會根據縮放等級、地圖中心 (以 LatLng 的形式表示) 和內含 DOM 元素的尺寸,建立一個可視區域,並將這個定界框轉譯為像素座標。接下來,API 就可以按照邏輯判斷落在指定像素範圍內的所有地圖圖塊。每個地圖圖塊都可用圖塊座標參照,因此能大幅簡化地圖圖像的顯示作業。
圖塊座標
API 無法在較高的縮放等級下,一次載入所有地圖圖像,而是會將各個縮放等級的圖像,分解成一組依照應用程式理解的邏輯順序排列的地圖圖塊。地圖捲動到新位置或調至新的縮放等級時,API 會使用像素座標來判斷需要哪些圖塊,然後將這些值轉譯成要擷取的一組圖塊。系統會利用一套可依照邏輯輕易判斷的配置指定這些圖塊座標;透過這套配置,即可得知哪些圖塊包含任意特定點的圖像。
Google 地圖中的圖塊是從與像素原點相同的位置開始編號。在 Google 的麥卡托投影實作中,原點圖塊一律位於地圖的西北角,同時 x 值會從西到東遞增,y 值則從北到南遞增。圖塊是使用從該原點開始的 x,y 座標來建立索引。舉例來說,縮放等級為 2 時,如果將地球區分成 16 個圖塊,每個圖塊都可使用不重複的 x,y 組合參照:
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2024-07-01 (世界標準時間)。"],[[["\u003cp\u003eThe Maps SDK for Android uses four coordinate systems: latitude/longitude, world, pixel, and tile coordinates.\u003c/p\u003e\n"],["\u003cp\u003eWorld coordinates are based on the Mercator projection and represent locations independent of zoom level.\u003c/p\u003e\n"],["\u003cp\u003ePixel coordinates denote a specific pixel on the map at a given zoom level, calculated using world coordinates and zoom level.\u003c/p\u003e\n"],["\u003cp\u003eTile coordinates simplify map imagery display by dividing the map into a grid of tiles, referenced by x,y coordinates.\u003c/p\u003e\n"],["\u003cp\u003eTile coordinates are derived from pixel coordinates and zoom level, facilitating efficient loading of map imagery.\u003c/p\u003e\n"]]],["The Maps SDK uses four coordinate systems: latitude/longitude (WGS84 standard), world, pixel, and tile. World coordinates, derived via Mercator projection, represent locations on the map relative to a base tile at zoom level 0. Pixel coordinates, calculated as `worldCoordinate * 2^zoomLevel`, specify pixels at specific zoom levels. Tile coordinates, determined by dividing pixel coordinates by tile size (256), reference specific map tiles for loading imagery. Each coordinate type is essential for rendering and managing map data.\n"],null,[]]