Quando você personaliza um estilo de mapa, isso ajuda a entender como a estilização de diferentes elementos pode afetar outros estilos no mapa. Várias camadas se sobrepõem:
Mapa de base: quando você começa a criar um estilo de mapa, é mostrado o estilo do mapa de base, ou seja, o padrão. Os elementos que você não personaliza mantêm esse estilo.
Estilos de mapa: os estilos personalizados substituem aqueles na camada do mapa de base.
Nesta imagem, o estilo personalizado substitui as áreas urbanas pelo ciano e as vias pelo azul-escuro.
Elementos de estilo: os elementos do mapa têm uma ou mais características que você pode personalizar. Nesta imagem, a cor de preenchimento do polígono nas áreas urbanas é ciano, e na malha rodoviária, é azul.
Hierarquia de elementos do mapa
No estilo de mapa, os elementos são organizados em hierarquia, com quatro elementos amplos na parte de cima e todos os outros organizados abaixo deles, em uma hierarquia lógica. Por padrão, um elemento do mapa herda os estilos do elemento acima dele na hierarquia (o principal). É possível substituir o estilo de nível superior definindo um ou mais dos elementos de estilo para os itens abaixo dele (elementos secundários). Consulte detalhes sobre a hierarquia de elementos em O que você pode estilizar no mapa.
Em cada elemento do mapa, você pode personalizar uma ou mais características ou partes do elemento. Por exemplo, a cor de preenchimento do polígono (a forma do elemento) é uma característica, assim como a cor do traço do rótulo de texto. Você ajusta de forma separada o estilo de cada elemento. Os elementos que não são editados mantêm o estilo padrão. Como os elementos são diferentes, é possível mudar a cor de preenchimento do texto do rótulo e manter a cor padrão do traço (contorno) ou herdar o que um estilo principal usa.
Confira a seguir algumas diretrizes úteis que explicam como funcionam a herança e a hierarquia de estilos.
Estilos secundários padrão herdam conteúdo do principal: para que todos os elementos secundários do mapa herdem um estilo, defina o estilo do elemento principal e mantenha o padrão no estilo secundário.
Estilos personalizados secundários substituem o principal: para substituir o estilo principal, defina um personalizado no elemento secundário.
Os elementos de estilo são independentes: as características que você define para um elemento do mapa (por exemplo, o preenchimento e o traço do polígono e do ícone/texto do rótulo) são independentes umas das outras. Quando você escolhe a cor do polígono, mas não a do ícone, o estilo do polígono substitui o principal, mas o ícone herda o estilo padrão ou principal.
Desative a visibilidade para ocultar elementos do mapa: se quiser que apenas um elemento apareça no mapa, desabilite a visibilidade de todos os itens.
Exemplo de hierarquia e herança
Este exemplo mostra como funcionam a herança e a hierarquia.
Selecione o elemento de nível superior do tipo Naturais e defina a cor de preenchimento do polígono como amarela. Todos os polígonos de elementos do mapa abaixo de Naturais serão amarelos:
Para que o Terreno, que fica abaixo de Naturais, também apareça em amarelo, não faça nada. Ele vai herdar o estilo de Naturais.
Para que as florestas fiquem em verde, abra Floresta abaixo de Terreno e pinte o polígono dessa cor. O estilo secundário personalizado substitui os estilos de Terreno e Naturais.
Para que o gelo seja mostrado em ciano-claro, abra Gelo (também abaixo de Terreno) e pinte o polígono dessa cor.
Por fim, se você quiser que a água fique em ciano, selecione Naturais > Água e pinte o polígono dessa cor. Definir o estilo secundário Água substitui o estilo principal de Naturais.
Siga o mesmo processo para destacar os elementos do mapa como precisar.
[null,null,["Última atualização 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."]]