Setting the visual appearance of displayed objects

YMapsML lets you determine the visual appearance of objects displayed on a map. Since visualization of YMapsML elements is performed using geo objects that have a preset appearance, we are basically talking about changing the standard method of displaying geo objects.

To change the visual appearance of displayed objects via YMapsML, styles are used. Styles let you set certain parameters for displaying geo objects and create a custom HTML representation using templates.

To define styles, use the repr:Style element. For templates, use repr:Template. To specify which style should be applied when displaying a geographical object or collection, use the ymaps:style element.

    <gml:pos>27.431259 38.621162</gml:pos>

Here, #customStyle is a link to the ID of the repr: Style element containing a style description. The link to the style ID is always prefixed by the “#” symbol.

The link can reference a style located not only in the current file, but also in external YMapsML files that can be accessed over HTTP. In this case, the link to the style is shown as <YMapsML file URL>#<style identifier>:


The sandbox has an example of loading a style from an external file.

When defining a geographical object or collection, you can link to a style, but not to a template. In other words, it is incorrect to link to the element repr:Template. Templates are used to define the HTML representation of geo objects that use styles. Techniques for using templates are described in the section Templates.