Map.setOptions
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
แก้ไขแผนที่ฐานของ Google Maps อนุญาตสำหรับ
1) การตั้งค่า MapType ปัจจุบัน 2) ระบุรูปแบบที่กำหนดเองสำหรับแผนที่ฐาน (MapTypeStyles) 3) ตั้งค่ารายการ mapTypesIds ที่ใช้ได้สำหรับแผนที่ฐาน
หากเรียกใช้โดยไม่มีพารามิเตอร์ ระบบจะรีเซ็ตประเภทแผนที่เป็นค่าเริ่มต้นของ Google
แสดงแผนที่
การใช้งาน | การคืนสินค้า |
---|
Map.setOptions(mapTypeId, styles, types) | ui.Map |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
mapTypeId | สตริง ไม่บังคับ | mapTypeId เพื่อตั้งค่าแผนที่ฐาน อาจเป็น "ROADMAP", "SATELLITE", "HYBRID" หรือ "TERRAIN" เพื่อเลือกประเภทแผนที่ Google Maps API มาตรฐาน หรือคีย์ใดคีย์หนึ่งที่ระบุไว้ในพจนานุกรม opt_styles หากปล่อยให้เป็น null และระบุสไตล์เพียง 1 รายการใน opt_styles ระบบจะใช้สไตล์นั้น |
styles | ออบเจ็กต์ (ไม่บังคับ) | พจนานุกรมของออบเจ็กต์ MapTypeStyle ที่กำหนดเองซึ่งมีคีย์เป็นชื่อที่จะปรากฏในการควบคุมประเภทแผนที่ของแผนที่ ดูที่ https://developers.google.com/maps/documentation/javascript/reference#MapTypeStyle |
types | List<String> ไม่บังคับ | รายการ mapTypeIds ที่จะทำให้พร้อมใช้งาน หากละเว้น แต่ระบุ opt_styles ระบบจะต่อท้ายคีย์สไตล์ทั้งหมดกับประเภทแผนที่ Google Maps API มาตรฐาน |
ตัวอย่าง
โปรแกรมแก้ไขโค้ด (JavaScript)
// Types
Map.setOptions('HYBRID');
Map.setOptions('ROADMAP');
Map.setOptions('SATELLITE');
Map.setOptions('TERRAIN');
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[[["\u003cp\u003eModifies the Google Maps basemap by setting the map type, providing custom styles, and controlling available map types.\u003c/p\u003e\n"],["\u003cp\u003eAccepts parameters to change the basemap's appearance or resets to the default Google Maps style when called without parameters.\u003c/p\u003e\n"],["\u003cp\u003eOffers flexibility in styling through custom MapTypeStyle objects and allows for selection from standard Google Maps API map types or custom styles.\u003c/p\u003e\n"],["\u003cp\u003eUses the \u003ccode\u003esetOptions()\u003c/code\u003e method with arguments for mapTypeId, styles, and types to implement the modifications.\u003c/p\u003e\n"],["\u003cp\u003eReturns the ui.Map object after applying the specified options.\u003c/p\u003e\n"]]],["This function, `Map.setOptions()`, modifies the Google Maps basemap. It can set the `mapTypeId` to \"ROADMAP,\" \"SATELLITE,\" \"HYBRID,\" or \"TERRAIN,\" or to a custom style from the `styles` dictionary. Custom styles (`styles`) are defined as `MapTypeStyle` objects. The available `mapTypeIds` displayed in the basemap can be defined in `types`. If called without arguments, the function reverts to the default Google map type. It returns the modified `ui.Map` object.\n"],null,["# Map.setOptions\n\n\u003cbr /\u003e\n\nModifies the Google Maps basemap. Allows for:\n\n\u003cbr /\u003e\n\n1) Setting the current MapType. 2) Providing custom styles for the basemap (MapTypeStyles). 3) Setting the list of available mapTypesIds for the basemap.\n\nIf called with no parameters, resets the map type to the google default.\n\nReturns the map.\n\n| Usage | Returns |\n|----------------------------------------------------------|---------|\n| `Map.setOptions(`*mapTypeId* `, `*styles* `, `*types*`)` | ui.Map |\n\n| Argument | Type | Details |\n|-------------|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `mapTypeId` | String, optional | A mapTypeId to set the basemap to. Can be one of \"ROADMAP\", \"SATELLITE\", \"HYBRID\" or \"TERRAIN\" to select one of the standard Google Maps API map types, or one of the keys specified in the opt_styles dictionary. If left as null and only 1 style is specified in opt_styles, that style will be used. |\n| `styles` | Object, optional | A dictionary of custom MapTypeStyle objects keyed with a name that will appear in the map's Map Type Controls. See: https://developers.google.com/maps/documentation/javascript/reference#MapTypeStyle |\n| `types` | List\\\u003cString\\\u003e, optional | A list of mapTypeIds to make available. If omitted, but opt_styles is specified, appends all of the style keys to the standard Google Maps API map types. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Types\nMap.setOptions('HYBRID');\nMap.setOptions('ROADMAP');\nMap.setOptions('SATELLITE');\nMap.setOptions('TERRAIN');\n```"]]