Khi tuỳ chỉnh kiểu bản đồ, bạn nên tìm hiểu cách tạo kiểu cho các đối tượng bản đồ khác nhau có thể ảnh hưởng đến các kiểu khác trên bản đồ. Có một số lớp chồng lên nhau:
Bản đồ cơ sở: Khi bắt đầu tạo một kiểu bản đồ, kiểu ban đầu mà bạn thấy là kiểu của bản đồ cơ sở; tức là bản đồ mặc định. Mọi đối tượng trên bản đồ mà bạn không tuỳ chỉnh sẽ giữ lại kiểu bản đồ cơ sở.
Kiểu bản đồ: Kiểu tuỳ chỉnh sẽ ghi đè các kiểu trên lớp bản đồ cơ sở.
Trong hình ảnh này, kiểu bản đồ tuỳ chỉnh sẽ ghi đè các khu vực đô thị thành màu xanh dương nhạt và đường thành màu xanh dương đậm.
Phần tử kiểu: Mỗi đối tượng trên bản đồ có một hoặc nhiều phần tử kiểu mà bạn có thể tuỳ chỉnh. Trong hình ảnh này, màu tô đa giác của đối tượng trên bản đồ khu vực đô thị được định kiểu là xanh dương nhạt và màu tô mạng lưới đường được định kiểu là xanh dương.
Hệ thống phân cấp đối tượng trên bản đồ
Trong một kiểu bản đồ, các đối tượng trên bản đồ được sắp xếp theo hệ thống phân cấp, với 4 đối tượng bản đồ rộng ở trên cùng và tất cả các đối tượng bản đồ khác được sắp xếp bên dưới theo một hệ thống phân cấp hợp lý. Theo mặc định, một đối tượng trên bản đồ sẽ kế thừa các kiểu phần tử cho đối tượng trên bản đồ ở phía trên trong hệ thống phân cấp (đối tượng mẹ); tuy nhiên, bạn có thể ghi đè kiểu cấp cao nhất bằng cách đặt một hoặc nhiều phần tử kiểu cho các đối tượng trên bản đồ ở bên dưới (đối tượng con trên bản đồ). Để biết thông tin chi tiết về hệ thống phân cấp đối tượng trên bản đồ, hãy xem phần Những đối tượng bạn có thể tạo kiểu trên bản đồ.
Mỗi đối tượng trên bản đồ đều có một hoặc nhiều phần tử (hoặc phần của đối tượng trên bản đồ) mà bạn có thể tạo kiểu. Ví dụ: màu tô cho đa giác (hình dạng đối tượng trên bản đồ) là một phần tử, cũng như màu nét vẽ cho nhãn văn bản. Bạn tạo kiểu cho từng phần tử riêng biệt và mọi phần tử bạn không tạo kiểu sẽ giữ lại kiểu mặc định. Vì các phần tử tách biệt nên bạn có thể tạo kiểu cho màu tô của văn bản nhãn và giữ nguyên màu nét vẽ (đường viền) ở chế độ mặc định (hoặc kế thừa từ kiểu mẹ).
Sau đây là một số nguyên tắc hữu ích giúp bạn hiểu cách hoạt động của hệ thống phân cấp và tính kế thừa của kiểu.
Kiểu con mặc định kế thừa từ kiểu mẹ: Để tất cả các đối tượng trên bản đồ con kế thừa một kiểu, hãy đặt kiểu cho đối tượng trên bản đồ mẹ và để kiểu con ở chế độ mặc định.
Kiểu con tuỳ chỉnh sẽ ghi đè kiểu gốc: Để ghi đè kiểu gốc, hãy đặt một kiểu tuỳ chỉnh cho đối tượng con.
Các phần tử kiểu độc lập: Các phần tử kiểu mà bạn có thể đặt cho một đối tượng trên bản đồ (ví dụ: đa giác, biểu tượng nhãn, màu tô và nét của văn bản nhãn) độc lập với nhau. Nếu bạn đặt màu đa giác nhưng không thay đổi biểu tượng, thì kiểu đa giác sẽ ghi đè kiểu mẹ, nhưng biểu tượng sẽ kế thừa kiểu mẹ hoặc kiểu mặc định.
Tắt chế độ Hiển thị để ẩn các đối tượng trên bản đồ: Nếu chỉ muốn xem một đối tượng trên bản đồ, bạn phải tắt chế độ hiển thị cho mọi đối tượng khác.
Ví dụ về hệ phân cấp và tính kế thừa
Dưới đây là một ví dụ về cách hoạt động của tính kế thừa và hệ thống phân cấp.
Chọn đối tượng bản đồ cấp cao nhất là Natural (Tự nhiên) rồi đặt Polygon Fill color (Màu tô đa giác) thành màu vàng. Thao tác này sẽ tạo kiểu cho tất cả đa giác cho các đối tượng trên bản đồ trong mục Tự nhiên thành màu vàng:
Bạn muốn Lớp phủ mặt đất (nằm trong mục Tự nhiên) cũng có màu vàng, vì vậy, bạn không tạo kiểu cho lớp này và lớp này sẽ kế thừa kiểu từ Tự nhiên.
Bạn muốn rừng có màu xanh lục, vì vậy trong phần Lớp phủ mặt đất, bạn mở Rừng và tô màu xanh lục cho đa giác của rừng. Kiểu con tuỳ chỉnh này sẽ ghi đè các kiểu cho Lớp phủ đất và Tự nhiên.
Bạn muốn băng có màu xanh dương nhạt, vì vậy, trong phần Lớp phủ mặt đất, bạn cũng mở Băng và tô màu đa giác của băng thành màu xanh dương nhạt.
Cuối cùng, bạn muốn nước có màu xanh dương nhạt, vì vậy, bạn chọn Natural>Water (Tự nhiên > Nước) rồi tô đa giác của nước bằng màu xanh dương nhạt. Việc đặt kiểu con là Water (Nước) sẽ ghi đè kiểu mẹ là Natural (Tự nhiên).
Hãy làm theo quy trình tương tự để làm nổi bật các đối tượng trên bản đồ theo nhu cầu của bạn.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[],[],null,["# Understand map style inheritance and hierarchy\n\nSelect platform: [Android](/maps/documentation/android-sdk/cloud-customization/map-hier \"View this page for the Android platform docs.\") [iOS](/maps/documentation/ios-sdk/cloud-customization/map-hier \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/cloud-customization/map-hier \"View this page for the JavaScript platform docs.\") [Web Service](/maps/documentation/maps-static/cloud-customization/map-hier \"View this page for the Web Service platform docs.\")\n\n\u003cbr /\u003e\n\n| To use cloud-based maps styling on Android, you must use the latest renderer for Maps SDK for Android. [Follow these instructions](/maps/documentation/android-sdk/renderer).\n\nWhen you customize a map style, it helps to understand how styling different map\nfeatures may affect other styles on the map. There are several layers that\noverlap:\n\n- **The base map**: When you start creating a map style, the initial\n you see is the style of the base map; that is, the default map. Any map\n features you don't customize retain the base map styling.\n\n- **Map styles**: Custom styles override the styles on the base map layer.\n In this image, the custom map style overrides the urban areas as aqua\n and roads as dark blue.\n\n- **Style elements**: Each map feature has one or more style elements that\n you can customize. In this image, the urban areas map feature polygon\n fill color is styled as aqua, and the road network fill color\n is styled as blue.\n\nMap feature hierarchy\n---------------------\n\nWithin a map style, map features are organized hierarchically, with 4 broad\nmap features at the top, and all other map features arranged beneath them in\na logical hierarchy. By default, a map feature inherits the element styles\nfor the map feature above it in the hierarchy (its parent); however, you\ncan override the top level style by setting one or more of the style elements\nfor map features underneath it (child map features). For details on the map\nfeature hierarchy, see [What you can style on a map](/maps/documentation/android-sdk/cloud-customization/taxonomy).\n\nEach map feature has one or more elements, or parts of the map feature, that\nyou can style. For example, the fill color for the polygon (the map feature\nshape) is an element, as is the stroke color for the text label. You style\neach element separately, and any element you don't style retains the default\nstyle. Since elements are separate, you can style the fill color for label\ntext, and leave the stroke (outline) color as the default (or inheriting\nfrom a parent style).\n\nHere are some helpful guidelines in understanding how style hierarchy and\ninheritance work.\n\n- **Default child styles inherit from the parent**: To have all\n child map features inherit a style, set the style for the parent map feature,\n and leave the child style as the default.\n\n- **Custom child styles override the parent**: To override the parent style,\n set a custom style on the child feature.\n\n- **Style elements are independent**: The style elements you can set for a\n map feature (for example, the polygon, the label icon, and the label text\n fill and stroke) are independent from each other. If you set the polygon\n color, but leave the icon alone, the polygon style overrides the parent\n style, but the icon inherits the parent or default style.\n\n- **Turn off Visibility to hide map features**: If you want to see only one\n thing on your map, you have to turn off visibility for everything else.\n\n | **Note:** When you hide map features or make them semi-transparent, you may expose boundary inaccuracies. Map feature boundaries are not always precise, but are adjusted to look correct when all layers are visible. For more details, see [Manage styles that overlap](/maps/documentation/android-sdk/cloud-customization/overlap).\n\nHierarchy and Inheritance Example\n---------------------------------\n\nHere is an example of how inheritance and hierarchy works.\n\n1. Select the top-level map feature of **Natural** , and set the\n **Polygon Fill color** to yellow. This styles all polygons for map\n features under **Natural** to be yellow:\n\n2. You want **Land cover** , which is under **Natural** , to also be yellow,\n so you leave it unstyled, and it inherits the style from **Natural**.\n\n3. You want forests to be green, so under **Land cover** , you open **Forest** ,\n and color its polygon green. This custom child style overrides the\n styles for **Land cover** and **Natural**.\n\n4. You want ice to be shown a pale aqua, so also under **Land cover** , you\n open **Ice**, and color its polygon pale aqua.\n\n5. And last, you want water to be aqua, so you select **Natural\\\u003eWater** , and\n color its polygon aqua. Setting the child style **Water** overrides the parent\n style for **Natural**.\n\nFollow a similar process to highlight the map features for your needs."]]