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, the repr:Style element is used; for templates, the repr:Template element is used. 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 that contains the 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 has the format <YMapsML file URL>#<template ID or inherited style ID>.


An example of loading a style from an external file is provided on the page.

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 repr:Templateelement. Templates are used to define the HTML representation of geo objects that use styles. Techniques for using templates are described in the section Templates.