Prześlij opinię
Omówienie kart 2D
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Deweloperzy z Europejskiego Obszaru Gospodarczego (EOG)
Jeśli Twój adres rozliczeniowy znajduje się w Europejskim Obszarze Gospodarczym, od 8 lipca 2025 r. do korzystania z usług będą miały zastosowanie Warunki korzystania z usługi Google Maps Platform w EOG. Więcej informacji
Ponadto niektóre treści z interfejsu Map Tiles API nie będą już zwracane.
Więcej informacji
Fragmenty mapy to po prostu podział świata na indeksowaną siatkę. Umożliwia to wydajny i dynamiczny dostęp do danych mapy i ich wykorzystywanie w różnych skalach kartograficznych. Interfejs Map Tiles API zapewnia dostęp do wielu tematycznych zbiorów danych geograficznych, w tym do tych opracowanych przez Google:
Kafelki z obrazami map drogowych oparte na wektorowych danych topograficznych ze stylizacją kartograficzną Google.
Ortofotografie wykonane przez kamery satelitarne i lotnicze, które dostarczają zdjęcia Ziemi z góry (w nadirze).
Mapy konturowe z cieniowaniem terenu.
Wszystkie fragmenty mapy 2D są georeferencyjne i wzajemnie dopasowane. Są one wybierane na podstawie zasięgu geograficznego widocznego obszaru i poziomu powiększenia. Poziomy powiększenia
wahają się od 0 (aby wyświetlić cały świat) do 22 (aby wyświetlić ulice i bloki).
Motywy mapy
Możesz pobrać kafelki mapy dla tych motywów:
Motyw mapy
Opis
Plan
drogi, budynki, ciekawe miejsca i granice polityczne;
Satelita
Zdjęcia wykonane z kosmosu
Teren
Mapa konturowa przedstawiająca naturalne elementy, takie jak roślinność
Uwaga: kafelki mapy mogą składać się z co najmniej 1 warstwy. Na przykład warstwę z mapą drogową można nałożyć na motyw mapy satelitarnej. Więcej informacji znajdziesz w sekcji Pola opcjonalne .
Aby wysyłać żądania dotyczące kafelków mapy do interfejsu Map Tiles API, musisz najpierw poprosić o token sesji . Token sesji śledzi bieżący stan mapy i obszaru widocznego. Podczas konfigurowania tokena sesji musisz ustawić wartość mapType
tak, aby pasowała do wybranego motywu mapy.
Następnie musisz uwzględnić token sesji w każdym żądaniu wysyłanym do interfejsu Map Tiles API.
Żądania informacji o widocznym obszarze
Widoczny obszar określa rozmiar ramki, w której wyświetlana jest scena świata. Żądania informacji o widocznym obszarze zwracają szczegóły dotyczące kafelków mapy, które składają się na bieżący widoczny obszar. Informacje o obszarze widoku są potrzebne, aby uniknąć wysyłania żądań dotyczących zdjęć na poziomach powiększenia, które nie istnieją.
Na przykład większość miast ma zdjęcia na poziomie powiększenia 22, ale nie ocean, ponieważ wyświetlałyby się tylko niebieskie kwadraty bez żadnych szczegółów.
Uwaga: w odpowiedzi znajdziesz informację o atrybucji, którą musisz wyświetlać na mapie, oraz maksymalny poziom powiększenia, dzięki czemu możesz utworzyć suwak powiększenia. Więcej informacji znajdziesz w zasadach interfejsu Map Tiles API .
Żądanie obszaru widoku to żądanie HTTPS GET w tej postaci:
curl "https://tile.googleapis.com/tile/v1/viewport ?session=YOUR_SESSION_TOKEN &key=YOUR_API_KEY &zoom=zoom &north=north &south=south &east=east &west=west "
Żądanie zawiera te pola:
zoom
Poziom powiększenia widocznego obszaru.
north
, south
, east
, west
Najbardziej wysunięte na północ, południe, wschód i zachód punkty w obszarze widoku wyrażone w stopniach. Wartości północ i południe muszą mieścić się w zakresie (-90,90), a wartości wschód i zachód w zakresie (-180, 180). Aby określić granice przekraczające południk zerowy, zachód może być dodatni (np. 170), a wschód ujemny (np. -170). Wszystkie parametry są wymagane.
Odpowiedzi dotyczące informacji o widocznym obszarze
Odpowiedź dotycząca widocznego obszaru informuje, które obszary mają zdjęcia i na jakich poziomach powiększenia. Odpowiedź z informacjami o obszarze wyświetlania ma następującą postać:
{
"copyright" : "Map data ©2023" ,
"maxZoomRects" : [
{
"maxZoom" : 19 ,
"north" : 90 ,
"south" : -90 ,
"east" : 180 ,
"west" : -180
},
{
"maxZoom" : 9 ,
"north" : 90 ,
"south" : -90 ,
"east" : 180 ,
"west" : -180
},
{
"maxZoom" : 14 ,
"north" : 84.375 ,
"south" : -84.375 ,
"east" : 180 ,
"west" : -180
}, ...
]
}
Uwaga: w tym przykładzie tablica maxZoomRects
zawiera więcej obiektów niż pokazano.
Treść odpowiedzi zawiera te pola:
copyright
Zawiera ciąg atrybucji, który musisz wyświetlać na mapie, gdy wyświetlasz kafelki mapy drogowej i satelitarnej. Więcej informacji znajdziesz w zasadach interfejsu Map Tiles API .
maxZoomRect
Zawiera tablicę prostokątów ograniczających, które nakładają się na bieżący obszar widoku. Zawiera też maksymalny poziom powiększenia dostępny w każdym prostokącie.
Funkcje współrzędnych kafelków
W większości języków programowania dostępne są narzędzia (proste funkcje), które umożliwiają konwertowanie par szerokości i długości geograficznej na współrzędne kafelków na określonym poziomie powiększenia.
Rozważmy ten przykładowy kod JavaScript, który najpierw przekształca wartość a
latLng
w punkt, a potem w współrzędne kafelka.
var TILE_SIZE = 256 ;
function fromLatLngToPoint ( latLng ) {
var mercator = - Math . log ( Math . tan (( 0.25 + latLng . lat () / 360 ) * Math . PI ));
return {
x : TILE_SIZE * ( latLng . lng () / 360 + 0.5 ),
y : TILE_SIZE / 2 * ( 1 + mercator / Math . PI )
};
}
function fromLatLngToTileCoord ( latLng , zoom ) {
var point = fromLatLngToPoint ( latLng );
var scale = Math . pow ( 2 , zoom );
return {
x : Math . floor ( point . x * scale / TILE_SIZE ),
y : Math . floor ( point . y * scale / TILE_SIZE ),
z : zoom
};
}
Prześlij opinię
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0 , a fragmenty kodu są dostępne na licencji Apache 2.0 . Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers . Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-09-04 UTC.
Chcesz przekazać coś jeszcze?
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-09-04 UTC."],[[["\u003cp\u003eMap Tiles API allows access to various thematic geodatasets like roadmap, orthophotography, and hillshade, dividing the world into an indexed grid for efficient data utilization.\u003c/p\u003e\n"],["\u003cp\u003eMap tiles are available in roadmap, satellite, and terrain themes, and can be overlaid for richer visualizations.\u003c/p\u003e\n"],["\u003cp\u003eA session token is required for accessing Map Tiles API, which tracks the map state and desired theme.\u003c/p\u003e\n"],["\u003cp\u003eViewport information requests help determine available zoom levels and imagery for a specific area to avoid requesting non-existent data.\u003c/p\u003e\n"],["\u003cp\u003eTile coordinate functions can be used to convert latitude/longitude pairs into tile coordinates for specific zoom levels, enabling precise map tile retrieval.\u003c/p\u003e\n"]]],["Map Tiles API provides access to geodatasets, including roadmap, satellite, and terrain themes, divided into an indexed grid. Users request a session token and specify a map theme. Viewport information, obtained via HTTPS GET requests, determines the available imagery and zoom levels (0-22) within a defined area. Responses include copyright attribution and maximum zoom levels. Tile coordinate functions convert latitude/longitude to tile coordinates for specific zoom levels.\n"],null,["# 2D Tiles overview\n\n**European Economic Area (EEA) developers** If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google\n| Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. [Learn more](/maps/comms/eea/faq). In addition, certain content from the Map Tiles API will no longer be returned. [Learn more](/maps/comms/eea/map-tiles).\n\nMap Tiles are simply the division of the world into an indexed\ngrid. It lets you access and utilize map data efficiently and dynamically\nat multiple cartographic scales. Map Tiles API gives you access to\nmultiple thematic geodatasets, including Google-curated:\n\n- Roadmap image tiles based on vector topographic data with Google's\n cartographic styling.\n\n- Orthophotography captured by both satellite and airborne cameras that deliver\n top down (nadir) imagery of the earth.\n\n- Hillshade contour maps.\n\n2D Map Tiles are all georeferenced and aligned to each other. They're selected\nbased on the geographic extent of the viewport and the zoom level. Zoom levels\nrange from zero (to view the world in its entirety) to 22 (to view streets and\nblocks).\n\nMap themes\n----------\n\nYou can get map tiles for the following map themes.\n\n| Map theme | Description |\n|-------------------------------------------------|----------------------------------------------------------------|\n| [Roadmap](/maps/documentation/tile/roadmap) | Roads, buildings, points of interest, and political boundaries |\n| [Satellite](/maps/documentation/tile/satellite) | Photographic imagery taken from space |\n| [Terrain](/maps/documentation/tile/terrain) | A contour map that shows natural features such as vegetation |\n\n| **Note:** Map tiles can consist of one or more layers. For example, a roadmap layer can be overlaid on top of a satellite map theme. For more information, see [Optional fields](/maps/documentation/tile/session_tokens#optional_fields).\n\nTo request map tiles from Map Tiles API, you must first request a\n[session token](/maps/documentation/tile/session_tokens). The session token\ntracks the current state of your map and viewport. When you set up your session\ntoken, you must set the `mapType` value to match the map theme that you want.\nThen, you must include the session token in each of your requests to\nMap Tiles API.\n\nViewport information requests\n-----------------------------\n\nThe viewport defines the size of the box that frames the world scene. Viewport\ninformation requests return details about the map tiles that make up your\ncurrent viewport. The reason that you request viewport information is to ensure\nthat you avoid requesting imagery at zoom levels that don't exist.\n\nFor example, most cities have imagery at zoom level 22, but not the ocean since\nit would just end up displaying featureless blue squares.\n| **Note:** Included in the response is the attribution that you must display with your map, and the maximum zoom level---so you can build a zoom slider. For more information, see the [Map Tiles API Policies](/maps/documentation/tile/policies#map-tiles-api).\n\nThe viewport request is an HTTPS GET request in the following form. \n\n```json\ncurl \"https://tile.googleapis.com/tile/v1/viewport?session=\u003cvar class=\"apiparam\" translate=\"no\"\u003eYOUR_SESSION_TOKEN\u003c/var\u003e&key=YOUR_API_KEY&zoom=\u003cvar class=\"apiparam\" translate=\"no\"\u003ezoom\u003c/var\u003e&north=\u003cvar class=\"apiparam\" translate=\"no\"\u003enorth\u003c/var\u003e&south=\u003cvar class=\"apiparam\" translate=\"no\"\u003esouth\u003c/var\u003e&east=\u003cvar class=\"apiparam\" translate=\"no\"\u003eeast\u003c/var\u003e&west=\u003cvar class=\"apiparam\" translate=\"no\"\u003ewest\u003c/var\u003e\"\n```\n\nThe request contains the following fields:\n\n`zoom`\n: The zoom level of the viewport.\n\n`north`, `south`, `east`, `west`\n: The furthest north, south, east, and west points in the viewport, expressed in\n degrees. North and south must be in the range (-90,90), east and west must be in\n the range (-180, 180). To express bounds crossing the antimeridian, west can be\n positive (for example, 170) and east can be negative (for example, -170). All\n parameters are required.\n\nViewport information responses\n------------------------------\n\nThe viewport response tells you which areas have imagery, and at which zoom\nlevels. A viewport information response has the following form. \n\n {\n \"copyright\": \"Map data ©2023\",\n \"maxZoomRects\": [\n {\n \"maxZoom\": 19,\n \"north\": 90,\n \"south\": -90,\n \"east\": 180,\n \"west\": -180\n },\n {\n \"maxZoom\": 9,\n \"north\": 90,\n \"south\": -90,\n \"east\": 180,\n \"west\": -180\n },\n {\n \"maxZoom\": 14,\n \"north\": 84.375,\n \"south\": -84.375,\n \"east\": 180,\n \"west\": -180\n }, ...\n ]\n }\n\n| **Note:** In this example, the `maxZoomRects` array contains more objects than is shown.\n\nThe response body contains the following fields.\n\n`copyright`\n: Contains an attribution string that you must display on your map when you\n display roadmap and satellite tiles. For more information, see the\n [Map Tiles API Policies](/maps/documentation/tile/policies#map-tiles-api).\n\n`maxZoomRect`\n: Contains an array of bounding rectangles that overlap with the current\n viewport. Also contains the maximum zoom level available within each rectangle.\n\nTile coordinate functions\n-------------------------\n\nTools (simple functions) are available in most programming languages to convert\nfrom latitude/longitude pairs to tile coordinates at a specific zoom level.\nConsider the following JavaScript code example that first converts from a\n`latLng` to a point, and then from a point to tile coordinates. \n\n var TILE_SIZE = 256;\n\n function fromLatLngToPoint(latLng) {\n var mercator = -Math.log(Math.tan((0.25 + latLng.lat() / 360) * Math.PI));\n return {\n x: TILE_SIZE * (latLng.lng() / 360 + 0.5),\n y: TILE_SIZE / 2 * (1 + mercator / Math.PI)\n };\n }\n\n function fromLatLngToTileCoord(latLng, zoom) {\n var point = fromLatLngToPoint(latLng);\n var scale = Math.pow(2, zoom);\n\n return {\n x: Math.floor(point.x * scale / TILE_SIZE),\n y: Math.floor(point.y * scale / TILE_SIZE),\n z: zoom\n };\n }"]]