Die Google Maps API umfasst Kartenkacheln für verschiedene Zoomstufen für Kartenbilder. Die meisten Bilder für Straßenkarten sind z. B. in den Zoomstufen 0 bis 18 verfügbar. Satellitenbilder variieren stärker, da sie nicht generiert, sondern direkt fotografiert werden.
Da Satellitenbilder für abgelegene Orte – kaum besiedelte Gebiete oder das offene Meer – nicht immer in hohen Zoomstufen verfügbar sind, kann es sinnvoll sein, die höchste Zoomstufe für die Bilder eines bestimmten Ortes im Voraus zu ermitteln. Das MaxZoomService-Objekt bietet eine einfache Schnittstelle zum Ermitteln der maximalen Zoomstufe an einem Ort, für den Google Maps Satellitenbilder zur Verfügung stellen kann.
MaxZoom-Anfragen
Der Zugriff auf MaxZoomService erfolgt asynchron, da die Google Maps API dazu einen externen Server aufrufen muss. Daher muss eine Callback-Methode übergeben werden, die nach Abschluss der Anfrage ausgeführt wird. Das Ergebnis wird dann über die Callback-Methode verarbeitet.
Zum Initiieren einer Anfrage an MaxZoomService rufen Sie getMaxZoomAtLatLng() auf, wodurch die LatLng-Werte des Ortes sowie eine Callback-Funktion übergeben werden, die nach Abschluss der Anfrage ausgeführt werden soll.
MaxZoom-Antworten
Wenn getMaxZoomAtLatLng() die Callback-Funktion ausführt, werden diese zwei Parameter zurückgegeben:
status enthält den MaxZoomStatus der Anfrage.
zoom enthält die Zoomstufe. Wenn beim Ausführen des Diensts ein Fehler auftritt, wird kein Wert angezeigt.
Der status-Code gibt einen der folgenden Werte zurück:
OK gibt an, dass der Dienst die maximale Zoomstufe für Satellitenbilder ermittelt hat.
ERROR gibt an, dass die MaxZoom-Anfrage nicht verarbeitet werden konnte.
Im folgenden Beispiel ist eine Karte des Großraums Tokio zu sehen. Durch Klicken auf eine beliebige Stelle der Karte wird die maximale Zoomstufe für den jeweiligen Ort angezeigt. Die Zoomstufen für den Großraum Tokio liegen in der Regel zwischen 18 und 21.
TypeScript
letmap:google.maps.Map;letmaxZoomService:google.maps.MaxZoomService;letinfoWindow:google.maps.InfoWindow;functioninitMap():void{map=newgoogle.maps.Map(document.getElementById("map")asHTMLElement,{zoom:11,center:{lat:35.6894,lng:139.692},mapTypeId:"hybrid",});infoWindow=newgoogle.maps.InfoWindow();maxZoomService=newgoogle.maps.MaxZoomService();map.addListener("click",showMaxZoom);}functionshowMaxZoom(e:google.maps.MapMouseEvent){maxZoomService.getMaxZoomAtLatLng(e.latLngasgoogle.maps.LatLng,(result:google.maps.MaxZoomResult)=>{if(result.status!=="OK"){infoWindow.setContent("Error in MaxZoomService");}else{infoWindow.setContent("The maximum zoom at this location is: "+result.zoom);}infoWindow.setPosition(e.latLng);infoWindow.open(map);});}declareglobal{interfaceWindow{initMap:()=>void;}}window.initMap=initMap;
letmap;letmaxZoomService;letinfoWindow;functioninitMap(){map=newgoogle.maps.Map(document.getElementById("map"),{zoom:11,center:{lat:35.6894,lng:139.692},mapTypeId:"hybrid",});infoWindow=newgoogle.maps.InfoWindow();maxZoomService=newgoogle.maps.MaxZoomService();map.addListener("click",showMaxZoom);}functionshowMaxZoom(e){maxZoomService.getMaxZoomAtLatLng(e.latLng,(result)=>{if(result.status!=="OK"){infoWindow.setContent("Error in MaxZoomService");}else{infoWindow.setContent("The maximum zoom at this location is: "+result.zoom,);}infoWindow.setPosition(e.latLng);infoWindow.open(map);});}window.initMap=initMap;
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-10 (UTC)."],[[["\u003cp\u003eThe Google Maps \u003ccode\u003eMaxZoomService\u003c/code\u003e helps determine the highest zoom level available for satellite imagery at a specific location.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eMaxZoomService\u003c/code\u003e requests are asynchronous and require a callback function to handle the response, which includes a status and zoom level.\u003c/p\u003e\n"],["\u003cp\u003eThe response status can be \u003ccode\u003eOK\u003c/code\u003e indicating success or \u003ccode\u003eERROR\u003c/code\u003e if the request failed.\u003c/p\u003e\n"],["\u003cp\u003eA provided example demonstrates using the \u003ccode\u003eMaxZoomService\u003c/code\u003e to display the maximum zoom level when clicking on a map of Tokyo.\u003c/p\u003e\n"]]],["The `MaxZoomService` determines the highest zoom level for satellite imagery at a given location. It uses `getMaxZoomAtLatLng()` with a location's `LatLng` and a callback function. The callback returns a `status` (`OK` or `ERROR`) and the `zoom` level. Clicking on a map in the provided example triggers `getMaxZoomAtLatLng()`, which updates an info window with the maximum zoom level or an error message. Access to this service is asynchronous and requires a callback to process results.\n"],null,["1. [Maximum Zoom Imagery](#MaxZoom)\n2. [MaxZoom Requests](#MaxZoomRequests)\n3. [MaxZoom Responses](#MaxZoomResponses)\n\nOverview Also see the Maps JavaScript API Reference: [Max Zoom](/maps/documentation/javascript/reference/max-zoom)\n\nThe Google Maps API provides map tiles at various\n[zoom levels](/maps/documentation/javascript/tutorial#MapOptions) for map type imagery. Most roadmap\nimagery is available from zoom levels 0 to 18, for\nexample. Satellite imagery varies more widely as this\nimagery is not generated, but directly photographed.\n\nBecause satellite imagery is not always available at\nhigh zoom levels for remote locations --- sparsely populated\nareas or open ocean areas --- you may want to\nknow the highest zoom level for imagery at a given location\nbeforehand. The `MaxZoomService` object provides a\nsimple interface for discovering the maximum zoom level at a\ngiven location for which Google Maps has satellite imagery.\n\nMaxZoom Requests\n\nAccessing the `MaxZoomService` is asynchronous, since the\nGoogle Maps API needs to make a call to an external server. For\nthat reason, you need to pass a *callback* method to execute\nupon completion of the request. This callback method should process\nthe result.\n\nTo initiate a request to the `MaxZoomService`,\ncall `getMaxZoomAtLatLng()`, passing the\n`LatLng` of the location and a callback function\nto execute upon completion of the request.\n\nMaxZoom Responses\n\nWhen `getMaxZoomAtLatLng()` executes the *callback*\nfunction, it will pass back two parameters:\n\n- `status` contains the `MaxZoomStatus` of the request.\n- `zoom` contains the zoom level. If for some reason the service fails, this value will not be present.\n\nThe `status` code may return one of the following values:\n\n- `OK` indicates that the service found the maximum zoom level for satellite imagery.\n- `ERROR` indicates that the MaxZoom request could not be processed.\n\nThe following example shows a map of metropolitan Tokyo.\nClicking anywhere on the map indicates the maximum zoom level\nat that location. (Zoom levels around Tokyo generally vary\nbetween zoom levels 18 and 21.) \n\nTypeScript \n\n```typescript\nlet map: google.maps.Map;\nlet maxZoomService: google.maps.MaxZoomService;\nlet infoWindow: google.maps.InfoWindow;\n\nfunction initMap(): void {\n map = new google.maps.Map(document.getElementById(\"map\") as HTMLElement, {\n zoom: 11,\n center: { lat: 35.6894, lng: 139.692 },\n mapTypeId: \"hybrid\",\n });\n\n infoWindow = new google.maps.InfoWindow();\n\n maxZoomService = new google.maps.MaxZoomService();\n\n map.addListener(\"click\", showMaxZoom);\n}\n\nfunction showMaxZoom(e: google.maps.MapMouseEvent) {\n maxZoomService.getMaxZoomAtLatLng(\n e.latLng as google.maps.LatLng,\n (result: google.maps.MaxZoomResult) =\u003e {\n if (result.status !== \"OK\") {\n infoWindow.setContent(\"Error in MaxZoomService\");\n } else {\n infoWindow.setContent(\n \"The maximum zoom at this location is: \" + result.zoom\n );\n }\n\n infoWindow.setPosition(e.latLng);\n infoWindow.open(map);\n }\n );\n}\n\ndeclare global {\n interface Window {\n initMap: () =\u003e void;\n }\n}\nwindow.initMap = initMap;https://github.com/googlemaps/js-samples/blob/2683f7366fb27829401945d2a7e27d77ed2df8e5/samples/maxzoom-simple/index.ts#L8-L49\n```\n| **Note:** Read the [guide](/maps/documentation/javascript/using-typescript) on using TypeScript and Google Maps.\n\nJavaScript \n\n```javascript\nlet map;\nlet maxZoomService;\nlet infoWindow;\n\nfunction initMap() {\n map = new google.maps.Map(document.getElementById(\"map\"), {\n zoom: 11,\n center: { lat: 35.6894, lng: 139.692 },\n mapTypeId: \"hybrid\",\n });\n infoWindow = new google.maps.InfoWindow();\n maxZoomService = new google.maps.MaxZoomService();\n map.addListener(\"click\", showMaxZoom);\n}\n\nfunction showMaxZoom(e) {\n maxZoomService.getMaxZoomAtLatLng(e.latLng, (result) =\u003e {\n if (result.status !== \"OK\") {\n infoWindow.setContent(\"Error in MaxZoomService\");\n } else {\n infoWindow.setContent(\n \"The maximum zoom at this location is: \" + result.zoom,\n );\n }\n\n infoWindow.setPosition(e.latLng);\n infoWindow.open(map);\n });\n}\n\nwindow.initMap = initMap;https://github.com/googlemaps/js-samples/blob/2683f7366fb27829401945d2a7e27d77ed2df8e5/dist/samples/maxzoom-simple/docs/index.js#L7-L37\n```\n| **Note:** The JavaScript is compiled from the TypeScript snippet.\n[View example](/maps/documentation/javascript/examples/maxzoom-simple)\n\nTry Sample \n[JSFiddle.net](https://jsfiddle.net/gh/get/library/pure/googlemaps/js-samples/tree/master/dist/samples/maxzoom-simple/jsfiddle) [Google Cloud Shell](https://ssh.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fgooglemaps%2Fjs-samples&cloudshell_git_branch=sample-maxzoom-simple&cloudshell_tutorial=cloud_shell_instructions.md&cloudshell_workspace=.)"]]