reviewsהשקת Places UI Kit: ספריית רכיבים מוכנה לשימוש בעלות נמוכה, שמאפשרת לכם להוסיף לכל מפה שתבחרו את ממשק המשתמש המוכר של 'מקומות' במפות Google. כדאי לנסות אותו ולשלוח לנו משוב כדי לעזור לנו לעצב את העתיד של GMP.
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Maps JavaScript API מציע שני יישומים שונים של המפה: רסטר ו-vector. מפת הרסטר נטענת כברירת מחדל, והיא נטענת כמטריצה של משבצות תמונות רסטר מבוססות-פיקסלים, שנוצרות בצד השרת של הפלטפורמה של מפות Google, ואז מוגשות לאפליקציית האינטרנט. מפת הווקטור מורכבת ממשבצות מבוססות-ווקטור, שמצוירות בזמן הטעינה בצד הלקוח באמצעות WebGL, טכנולוגיית אינטרנט שמאפשרת לדפדפן לגשת ל-GPU במכשיר של המשתמש כדי לעבד גרפיקה דו-ממדית ותלת-ממדית. מומלץ להשתמש במפה וקטורית כדי לספק את חוויית המשתמש הטובה ביותר, כי היא מספקת נאמנות חזותית משופרת וגם מאפשרת לשלוט בהטיה ובכיוון במפה.
מידע נוסף על התכונות של מפות וקטוריות
מגדירים את סוג העיבוד של מפה על ידי ציון האפשרות renderingType map
או על ידי הגדרת האפשרות במזהה מפה משויך. האפשרות renderingType
מבטלת את ההגדרות של סוג העיבוד שנקבעו בהגדרת מזהה המפה.
ציון האפשרות renderingType
אפשר להשתמש באפשרות renderingType כדי לציין את סוג העיבוד של המפה (רסטר או וקטור) (לא נדרש מזהה מפה). במפות שנטענות באמצעות רכיב div
ו-JavaScript, סוג העיבוד שמוגדר כברירת מחדל הוא google.maps.RenderingType.RASTER. כדי להגדיר את האפשרות renderingType
פועלים לפי השלבים הבאים:
טוענים את ספריית RenderingType. אפשר לעשות זאת כשמטעינים את ספריית Maps:
כשמגדירים את סוג העיבוד של מפת הווקטור, צריך להגדיר את האפשרויות של התכונות הנדרשות.
כדי להפעיל את ההטיה, מגדירים את אפשרות המפה tiltInteractionEnabled ל-true או מתקשרים אל
map.setTiltInteractionEnabled(true).
כדי להפעיל את ההזזה, מגדירים את אפשרות המפה headingInteractionEnabled ל-true
או מתקשרים אל map.setHeadingInteractionEnabled(true).
במפות שנטענות באמצעות רכיב <gmp-map>, סוג העיבוד שמוגדר כברירת מחדל הוא google.maps.RenderingType.VECTOR, עם אפשרות להטיה ושליטה בכיוון. כדי להגדיר את סוג העיבוד באמצעות הרכיב <gmp-map>, צריך להשתמש במאפיין rendering-type.
שימוש במזהה מפה כדי להגדיר את סוג העיבוד
אפשר גם לציין את סוג העיבוד באמצעות מזהה מפה. כדי ליצור מזהה מפה חדש, פועלים לפי השלבים במאמר שימוש בסגנונות מפה מבוססי-Cloud – קבלת מזהה מפה.
חשוב להגדיר את סוג המפה ל-JavaScript ולבחור באחת מהאפשרויות (Vector או Raster). מסמנים את התיבות הטיה וסיבוב כדי להפעיל הטיה וסיבוב במפה. כך תוכלו לשנות את הערכים האלה באופן אוטומטי, וגם לאפשר למשתמשים לשנות את ההטיה והכיוון ישירות במפה. אם השימוש בהטיה או בכיוון ישפיע לרעה על האפליקציה, אל תסמנו את התיבות הטיה וסיבוב כדי שהמשתמשים לא יוכלו לשנות את ההטיה והסיבוב.
לאחר מכן, מעדכנים את קוד האתחול של המפה עם מזהה המפה שיצרתם. אפשר למצוא את מזהי המפות בדף ניהול מפות. מזינים מזהה מפה כשיוצרים מופע של המפה באמצעות המאפיין mapId כמו שמוצג כאן:
[[["התוכן קל להבנה","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-27 (שעון UTC)."],[[["\u003cp\u003eThe Maps JavaScript API offers two map types: raster (default) and vector (recommended for enhanced user experience with tilt and heading control).\u003c/p\u003e\n"],["\u003cp\u003eYou can set the rendering type using the \u003ccode\u003erenderingType\u003c/code\u003e map option or by associating a map ID with specific rendering settings.\u003c/p\u003e\n"],["\u003cp\u003eVector maps provide better visual quality and allow for tilt and heading manipulation, requiring enabling specific interactions for these features.\u003c/p\u003e\n"],["\u003cp\u003eMap IDs offer pre-configured rendering types and can be created and managed through the Cloud console, enabling customization without code changes.\u003c/p\u003e\n"],["\u003cp\u003eUsing a map ID and API key from the same Google Cloud project is recommended for optimal integration and management.\u003c/p\u003e\n"]]],[],null,["# Rendering type (raster and vector)\n\nThe Maps JavaScript API offers two different implementations of the map: raster\nand vector. The raster map is loaded by default, and loads the map as a grid of\npixel-based raster image tiles, which are generated by Google Maps Platform\nserver-side, then served to your web app. The vector map is a composed of\nvector-based tiles, which are drawn at load time on the client-side using\nWebGL, a web technology that allows the browser to access the GPU on the user's\ndevice to render 2D and 3D graphics. The vector map type is recommended for the\nbest user experience, as it provides improved visual fidelity as well as the\nability to control tilt and heading on the map.\n[Learn more about vector map features.](/maps/documentation/javascript/vector-map)\n\nSet the rendering type for a map either by specifying the `renderingType` map\noption, or by setting the option on an associated map ID. The `renderingType`\noption overrides any rendering type settings made by configuring a map ID.\n\nSpecify the `renderingType` option\n----------------------------------\n\nUse the `renderingType` option to specify either the raster or vector\nrendering type for your map (no map ID required). For maps loaded using a `div`\nelement and JavaScript, the default rendering type is\n`google.maps.RenderingType.RASTER`. Take these steps to set the `renderingType`\noption:\n\n1. Load the `RenderingType` library; this can be done when loading the Maps\n library:\n\n const { Map, RenderingType } = await google.maps.importLibrary(\"maps\");\n\n2. When initializing the map, use the `renderingType` option to specify either\n `RenderingType.VECTOR` or `RenderingType.RASTER`:\n\n map = new Map(\n document.getElementById('map'),\n {\n zoom: 4,\n center: position,\n renderingType: RenderingType.VECTOR,\n }\n );\n\nWhen the vector map rendering type is set, you must set the options for the\nneeded features.\n\n- To enable tilt, set the `tiltInteractionEnabled` map option to `true` or call `map.setTiltInteractionEnabled(true)`.\n- To enable panning, set the `headingInteractionEnabled` map option to `true` or call `map.setHeadingInteractionEnabled(true)`.\n\nFor maps loaded using the `\u003cgmp-map\u003e` element, the default rendering type is\n`google.maps.RenderingType.VECTOR`, with tilt and heading control enabled. To\nset the rendering type by using the `\u003cgmp-map\u003e` element, use the\n`rendering-type` attribute.\n\nUse a map ID to set rendering type\n----------------------------------\n\nYou can also specify the rendering type by using a map ID. To create a new map\nID, follow the steps in [Using Cloud-based Map Styling - Get a map ID](/maps/documentation/javascript/styling#creating-map-ids).\nBe sure to set the Map type to **JavaScript** , and select an option (**Vector**\nor **Raster** ). Check **Tilt** and **Rotation** to enable tilt and rotation\non the map. Doing so will allow you to programmatically adjust these values, and\nalso lets users adjust tilt and heading directly on the map. If the use of tilt\nor heading will adversely affect your app, leave **Tilt** and **Rotation** un-\nchecked so users will not be able to adjust tilt and rotation.\n\nNext, update your map initialization code with the map ID you created. You can\nfind your map IDs on the\n[Maps\nManagement](https://console.cloud.google.com/google/maps-apis/studio/maps) page. Provide a map ID when you instantiate the map using the\n`mapId` property as shown here: \n\n```javascript\nmap = new google.maps.Map(document.getElementById('map'), {\n center: {lat: -34.397, lng: 150.644},\n zoom: 8,\n mapId: '\u003cvar translate=\"no\"\u003eMAP_ID\u003c/var\u003e'\n});\n```\n| **Important:** It is recommended to associate your map ID and API key with the same Google Cloud console project."]]