repr:parentStyle

Diagram

Description

Sets the parent style ID.

Styles are inherited via repr:parentStyle. If a tag is not specified, style inheritance is from the default style.

Inheritance is only possible for tags that are directly nested in repr: Style (repr: iconStyle, repr: lineStyle, and so on).

A tag is inherited only if it is not present in the child style. If a tag is present but not fully defined (i.e., not all nested tags are defined), there will be no inheritance. YMapsML supports no partial inheritance.

Contained by:

repr:Style

repr:parentStyle

A YMapsML document demonstrating style inheritance.

In this example, style example#style2 uses styles inherited from the parent style example#style1 for displaying placemark icons (i.e., repr:iconStyle), while the repr:lineStyle tag will not be inherited, because it is defined in the example#style2 style.

Other style tags (repr: iconContentStyle, repr:hintContentStyle, and so on) are not defined in the parent style, so they will be assigned the default value.

<?xml version="1.0" encoding="utf-8"?>
<ymaps:ymaps xmlns:ymaps="http://maps.yandex.ru/ymaps/1.x"
             xmlns:gml="http://www.opengis.net/gml" 
             xmlns:repr="http://maps.yandex.ru/representation/1.x"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
             xsi:schemaLocation="http://maps.yandex.ru/schemas/ymaps/1.x/ymaps.xsd">
    <repr:Representation>
        <repr:Style gml:id="example#style1">
            <repr:iconStyle>
                <repr:href>http://info.maps.yandex.net/api/i/steelblue/dot.png</repr:href>
                <repr:size x="26" y="46"/>
                <repr:offset x="-22" y="-46"/>
            </repr:iconStyle>

            <repr:lineStyle>
                <repr:strokeColor>12345688</repr:strokeColor>
                <repr:strokeWidth>2</repr:strokeWidth>
            </repr:lineStyle>
        </repr:Style>
      
        <repr:Style gml:id="example#style2">
            <repr:parentStyle>example#style1</repr:parentStyle>
            <repr:lineStyle>
                <repr:strokeColor>77382250</repr:strokeColor>
                <repr:strokeWidth>4</repr:strokeWidth>
            </repr:lineStyle>
        </repr:Style>
    </repr:Representation>
</ymaps:ymaps>