reviewsהשקת Places UI Kit: ספריית רכיבים מוכנה לשימוש בעלות נמוכה, שמאפשרת לכם להוסיף לכל מפה שתבחרו את ממשק המשתמש המוכר של 'מקומות' במפות Google. כדאי לנסות אותו ולשלוח לנו משוב כדי לעזור לנו לעצב את העתיד של GMP.
שכבות
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
בחירת פלטפורמה:
Android
JavaScript
שכבות הן אובייקטים במפה שכוללים פריט אחד או יותר, אבל אפשר לבצע בהם פעולות כיחידה אחת. בדרך כלל, שכבות משקפות אוספים של אובייקטים שמוסיפים מעל המפה כדי לציין שיוך משותף. ממשק ה-API של JavaScript במפות Google מנהל את הצגת האובייקטים בשכבות על ידי עיבוד הפריטים המרכיבים שלהם לאובייקט אחד (בדרך כלל שכבת-על של משבצות) והצגתם כששדה התצוגה של המפה משתנה. השכבות יכולות גם לשנות את שכבת התצוגה של המפה עצמה, ולשנות מעט את המשבצות הבסיסיות באופן שתואם לשכבה. חשוב לדעת שרוב השכבות, מעצם הגדרתן, לא ניתנות לגישה דרך העצמים הנפרדים שלהן, אלא רק כיחידה אחת.
סקירה כללית על שכבות
ב-Maps JavaScript API יש כמה סוגים של שכבות:
- השכבה 'נתוני מפות Google' מספקת מאגר לנתונים גיאו-מרחביים שרירותיים.
אפשר להשתמש בשכבת הנתונים כדי לאחסן נתונים מותאמים אישית, או כדי להציג נתוני GeoJSON במפה של Google.
-
שכבת מפת החום מאפשרת להציג נתונים גאוגרפיים באמצעות מפת חום.
-
השכבה של KML מייצרת רכיבי KML ו-GeoRSS כשכבת-על של משבצות ב-Maps JavaScript API.
-
השכבה 'תנועה' מציגה את תנאי התנועה במפה.
-
שכבת התחבורה הציבורית מציגה במפה את רשת התחבורה הציבורית של העיר.
- האובייקט
Bicycling layer יוצר שכבה של שבילי אופניים ו/או שכבות-על ספציפיות לאופניים בשכבה משותפת. השכבה הזו מוחזרת כברירת מחדל ב-DirectionsRenderer כשמבקשים מסלול בנסיעה באופניים.
הוספת שכבה
כדי להוסיף שכבה למפה, צריך רק להפעיל את setMap()
ולהעביר לה את אובייקט המפה שבו רוצים להציג את השכבה. באופן דומה, כדי להסתיר שכבה, קוראים ל-setMap()
ומעבירים את הערך null
.
קטע הקוד הבא מרכז את המפה בלונדון, בריטניה, ומוסיף את שכבת התחבורה הציבורית.
var mapOptions = {
zoom: 13,
center: new google.maps.LatLng(51.5,-0.11)
}
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
var transitLayer = new google.maps.TransitLayer();
transitLayer.setMap(map);
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-06 (שעון UTC).
[null,null,["עדכון אחרון: 2025-08-06 (שעון UTC)."],[[["\u003cp\u003eLayers in Maps JavaScript API are objects consisting of multiple items that are treated as a single unit and often represent collections of objects on the map.\u003c/p\u003e\n"],["\u003cp\u003eThe API provides various layer types, including Data, Heatmap, KML, Traffic, Transit, and Bicycling layers, each serving a distinct purpose for displaying geospatial data.\u003c/p\u003e\n"],["\u003cp\u003eYou can easily add or hide a layer by calling the \u003ccode\u003esetMap()\u003c/code\u003e method, providing the map object or \u003ccode\u003enull\u003c/code\u003e respectively.\u003c/p\u003e\n"],["\u003cp\u003eThe example code demonstrates adding a Transit layer to a map centered on London.\u003c/p\u003e\n"]]],[],null,["Select platform: [Android](/maps/documentation/android-sdk/utility/multilayer \"View this page for the Android platform docs.\") [JavaScript](/maps/documentation/javascript/layers \"View this page for the JavaScript platform docs.\")\n\nLayers are objects on the map that consist of one or more separate items,\nbut are manipulated as a single unit. Layers generally reflect collections of\nobjects that you add on top of the map to designate a common association. The\nMaps JavaScript API manages the presentation of objects within layers\nby rendering their constituent items into one object (typically a tile overlay) and\ndisplaying them as the map's viewport changes. Layers may also alter the presentation\nlayer of the map itself, slightly altering the base tiles in a fashion\nconsistent with the layer. Note that most layers, by design, may not be\naccessed via their individual objects, but may only be manipulated as a\nunit.\n\nLayers Overview\n\nThe Maps JavaScript API has several types of layers:\n\n- The [**Google Maps Data\n layer**](/maps/documentation/javascript/datalayer) provides a container for arbitrary geospatial data. You can use the Data layer to store your custom data, or to display GeoJSON data on a Google map.\n- The [**Heatmap layer**](/maps/documentation/javascript/heatmaplayer) renders geographic data using a *Heatmap* visualization.\n- The [**KML layer**](/maps/documentation/javascript/kmllayer) renders KML and GeoRSS elements into a Maps JavaScript API tile overlay.\n- The [**Traffic layer**](/maps/documentation/javascript/trafficlayer#traffic_layer) displays traffic conditions on the map.\n- The [**Transit layer**](/maps/documentation/javascript/trafficlayer#transit_layer) displays the public transport network of your city on the map.\n- The [**Bicycling layer**](/maps/documentation/javascript/trafficlayer#bicycling_layer) object renders a layer of bike paths and/or bicycle-specific overlays into a common layer. This layer is returned by default within the **DirectionsRenderer** when requesting directions of travel mode **BICYCLING**.\n\nAdd a layer\n\nTo add a layer to a map, you only need to call `setMap()`,\npassing it the map object on which to display the layer. Similarly, to hide a\nlayer, call `setMap()`, passing `null`.\n\nThe below snippet centers the map on London, UK, and adds the [Transit\nlayer](/maps/documentation/javascript/trafficlayer#transit_layer). \n\n```javascript\nvar mapOptions = {\n zoom: 13,\n center: new google.maps.LatLng(51.5,-0.11)\n}\n\nvar map = new google.maps.Map(document.getElementById(\"map\"), mapOptions);\n\nvar transitLayer = new google.maps.TransitLayer();\ntransitLayer.setMap(map);\n```"]]