توفّر Google Maps API مربّعات الخرائط بمستويات مختلفة لتكبير/تصغير الصور من النوع "خريطة". تتوفّر معظم صور خارطة الطريق من مستويات التكبير 0 إلى 18، مثلاً. تختلف صور الأقمار الصناعية على نطاق أوسع لأنّه لا يتم إنشاؤها، بل يتم تصويرها مباشرةً.
بما أنّ صور الأقمار الصناعية لا تتوفّر دائمًا عند استخدام مستويات تكبير أو تصغير عالية للمواقع الجغرافية البعيدة، مثل مناطق قليلة الكثافة السكانية أو مناطق المحيطات المفتوحة، ننصحك بمعرفة أعلى مستوى تكبير أو تصغير للصور في موقع جغرافي معيّن مسبقًا. يقدّم العنصر MaxZoomService واجهة بسيطة لاستكشاف الحد الأقصى لمستوى التكبير أو التصغير في موقع جغرافي معيّن تتوفّر له صور أقمار صناعية في "خرائط Google".
طلبات MaxZoom
يكون الوصول إلى MaxZoomService غير متزامن، لأنّ Google Maps API تحتاج إلى إجراء طلب إلى خادم خارجي. لهذا السبب، عليك تمرير طريقة رد اتصال لتنفيذ عند اكتمال الطلب. من المفترض أن تعالج طريقة ردّ الاتصال هذه النتيجة.
لبدء طلب إلى MaxZoomService، اتصل getMaxZoomAtLatLng()، مع تمرير LatLng للموقع الجغرافي ووظيفة طلب معاودة الاتصال لتنفيذها عند اكتمال الطلب.
استجابات MaxZoom
عندما ينفذ getMaxZoomAtLatLng() دالة callback ، سيُعيد مَعلمتَين:
يحتوي status على MaxZoomStatus للطلب.
يحتوي zoom على مستوى التكبير/التصغير. إذا تعذّر إتمام الخدمة لأي سبب، لن تكون هذه القيمة متوفّرة.
قد يعرض الرمز status إحدى القيم التالية:
يشير الرمز OK إلى أنّ الخدمة عثرت على الحد الأقصى لمستوى التكبير للصور من الأقمار الصناعية.
يشير الرمز ERROR إلى أنّه تعذّرت معالجة طلب MaxZoom.
يعرض المثال التالي خريطة لمدينة طوكيو الكبرى. يشير النقر في أي مكان على الخريطة إلى الحد الأقصى لمستوى التكبير في ذلك الموقع. (تختلف مستويات التكبير أو التصغير حول طوكيو بشكل عام بين مستويات التكبير أو التصغير 18 و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;
تاريخ التعديل الأخير: 2025-08-10 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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"]],["تاريخ التعديل الأخير: 2025-08-10 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\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=.)"]]