Map.onClick
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
פונקציה שרושמת קריאה חוזרת (callback) שמופעלת כשלוחצים על המפה.
מחזירה מזהה שאפשר להעביר אל unlisten() כדי לבטל את הרישום של הקריאה החוזרת.
שימוש | החזרות |
---|
Map.onClick(callback) | מחרוזת |
ארגומנט | סוג | פרטים |
---|
callback | פונקציה | הקריאה החוזרת שמופעלת כשלוחצים על המפה. פונקציית הקריאה החוזרת מקבלת אובייקט שמכיל את הקואורדינטות של הנקודה שנלחצה (עם המפתחות lon ו-lat) ואת הווידג'ט של המפה. |
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-26 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-26 (שעון UTC)."],[[["\u003cp\u003eRegisters a callback function that is triggered when the map is clicked, providing the coordinates of the click.\u003c/p\u003e\n"],["\u003cp\u003eReturns a unique ID that can be used to unregister the callback function later using \u003ccode\u003eunlisten()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eonClick\u003c/code\u003e accepts a single argument: a callback function which receives an object containing longitude, latitude, and the map widget.\u003c/p\u003e\n"]]],["A callback function is registered to be executed upon a map click. The `Map.onClick(callback)` method accepts this function as an argument and returns a unique string ID. This ID is used to unregister the callback later. The callback receives an object containing the longitude (`lon`), latitude (`lat`), and the map widget upon execution when a map click occurs.\n"],null,["# Map.onClick\n\n\u003cbr /\u003e\n\nRegisters a callback that's fired when the map is clicked.\n\n\u003cbr /\u003e\n\nReturns an ID which can be passed to unlisten() to unregister the callback.\n\n| Usage | Returns |\n|-------------------------|---------|\n| `Map.onClick(callback)` | String |\n\n| Argument | Type | Details |\n|------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `callback` | Function | The callback to fire when the map is clicked. The callback is passed an object containing the coordinates of the clicked point (with keys lon and lat) and the map widget. |"]]