Overview of YMapsML

YMapsML is an XML language intended for describing and displaying various geographical objects in the Yandex.Maps service.

For information about working with YMapsML via the Yandex.Maps JavaScript API, see the geoXML.load method description. YMapsML is also used in HTTP geocoder responses; see The geocoder response.

YMapsML is based on the XML standard and is an extension of the GML standard.

The root element of a YMapsML document is ymaps:ymaps. The attributes for this element define the XML namespace and the XSD schema being used.

The ymaps:ymaps element, in turn, can contain several tags that serve as containers for various data or groups of data that are displayed on a map.

attr:Attribution
A container for the attr:Source tag.
attr:Source
Contains information about who provided the information presented in the YMapsML document.
repr:Representation
A container for the repr:View, repr:Style and repr:Template tags.
repr:View
Intended for creating the initial state of a map. Use it to set the map center, type, and starting zoom level. The repr:View element can only occur once in a YMapsML document.
repr:Style
Defines styles of objects that are displayed on the map. In particular, you can use styles to describe how markers, lines, and other objects will look on the map. A YMapsML document can have any number of repr:Style elements.
repr:Template
Intended for defining templates for HTML layout of various map objects. A YMapsML document can have any number of repr:Template elements.
ymaps:GeoObjectCollection
A container for descriptions of the objects placed on a map. You can use this element to set shared properties, such as styles, for a set of graphical objects. The ymaps:GeoObjectCollection element can contain nested ymaps:GeoObjectCollection elements, but it can only be present once in the ymaps:ymaps element.

In general terms, a YMapsML document looks like this:

<?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:View>
            <repr:mapType>HYBRID</repr:mapType>
            <gml:boundedBy>
                <gml:Envelope>
                    <gml:lowerCorner>32.805985 39.915474</gml:lowerCorner>
                    <gml:upperCorner>32.858513 39.865093</gml:upperCorner>
                </gml:Envelope>
            </gml:boundedBy>
        </repr:View>

        <repr:Style gml:id="customStyle">
            <repr:parentStyle>default#greenPoint</repr:parentStyle>
            <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:shadow>
                    <repr:href>http://info.maps.yandex.net/api/i/dot_shadow.png</repr:href>
                    <repr:size x="25" y="23"/>
                    <repr:offset x="0" y="-25"/>
                </repr:shadow>
            </repr:iconStyle>

            <repr:lineStyle>
                <repr:strokeColor>ff003399</repr:strokeColor>
                <repr:strokeWidth>5</repr:strokeWidth>
            </repr:lineStyle>

            <repr:balloonContentStyle>
                <repr:template>#customTemplate</repr:template>
            </repr:balloonContentStyle>
        </repr:Style>

        <repr:Template gml:id="customTemplate">
            <repr:text><![CDATA[<div 
            style="color:blue">$[description]</div>]]></repr:text>
        </repr:Template>
    </repr:Representation>
    <Attribution>
        <Source id="source">
            <author>
                <name>Source name</name>
                <uri>maps.yandex.com.tr</uri>
            </author>
        </Source>
    </Attribution>
    <ymaps:GeoObjectCollection>
        <ymaps:style>#customStyle</ymaps:style>
        <gml:featureMembers>
            <ymaps:GeoObject>
                <gml:description>Description</gml:description>
                <gml:Point>
                    <gml:pos>32.830618 39.889957</gml:pos>
                </gml:Point>
            </ymaps:GeoObject>

            <ymaps:GeoObject>
                <gml:LinearRing>
                    <gml:pos>32.823752 39.894651</gml:pos>
                    <gml:pos>32.824009 39.883213</gml:pos>
                    <gml:pos>32.835597 39.882486</gml:pos>
                    <gml:pos>32.834395 39.895775</gml:pos>
                    <gml:pos>32.823752 39.894651</gml:pos>
                </gml:LinearRing>

            </ymaps:GeoObject>
        </gml:featureMembers>
    </ymaps:GeoObjectCollection>
</ymaps:ymaps>