A API Google Maps disponibiliza blocos de mapas em vários níveis de zoom para imagens de tipos de mapa. A maioria das imagens de roteiros, por exemplo, está disponível nos níveis de zoom de 0 a 18. As imagens de satélite variam mais, porque não são geradas, mas fotografadas diretamente.
Como as imagens de satélite nem sempre estão disponíveis em altos níveis de zoom em locais remotos, como áreas pouco povoadas ou no oceano, convém saber com antecedência o nível de zoom mais alto das imagens em um determinado local. O objeto MaxZoomService oferece uma interface simples para descobrir o nível de zoom máximo em um determinado local que tem imagens de satélite no Google Maps.
Solicitações de MaxZoom
O acesso ao MaxZoomService é assíncrono, porque a API Google Maps precisa fazer uma chamada para um servidor externo. Portanto, você precisa transmitir um método de callback a ser executado após a conclusão da solicitação. Esse método deve processar o resultado.
Para iniciar uma solicitação ao MaxZoomService, chame getMaxZoomAtLatLng(), transmitindo o LatLng do local e uma função de callback a ser executada após a solicitação ser concluída.
Respostas de MaxZoom
Quando executa a função de callback, getMaxZoomAtLatLng() devolve dois parâmetros:
status contém o objeto MaxZoomStatus da solicitação.
zoom contém o nível de zoom. Se o serviço falhar, este valor não vai aparecer.
O código status pode retornar um destes valores:
OK: indica que o serviço encontrou o nível de zoom máximo das imagens de satélite.
ERROR: indica que não foi possível processar a solicitação de MaxZoom.
O exemplo abaixo mostra um mapa da região metropolitana de Tóquio. Ao clicar em qualquer lugar do mapa, o nível de zoom máximo do local aparece. Os níveis de zoom ao redor de Tóquio costumam variar entre 18 e 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;
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 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=.)"]]