Setting geometric and geographical data

The section Geometric and geographical data lists the elements that are used for defining geometric properties of geographical objects. Each element corresponds to a geometric shape and a geo object that is used for displaying this shape on the map.

The geometric shape is bound to a locality by setting the coordinates of corresponding points. For a geometric point, its coordinates are set; for a polyline, the coordinates of its points; for a polygon, the coordinates of the points of the closed polylines that make up its exterior and interior edges.

The coordinates of points and polyline points are set using the gml:pos and gml:posList elements. To specify the coordinates that define the viewport or a polygon outline, the gml:lowerCorner and gml:upperCorner elements are used.

To set the coordinates of a point, its longitude and latitude are listed in order and separated by a space. For example: <gml:pos>55.0298 82.9197</gml:pos>. This is how coordinates are set for points that are described using the gml:pos, gml:lowerCorner, and gml:upperCorner elements. When setting coordinates for a sequence of points using the gml:posList element, pairs of point coordinates are separated by a space in the same way. For example, <gml:posList>55.0298 82.9197 55.0496 82.9694</gml:posList>.

Geometric point

To define the coordinates of a geometric point, use the gml: pos element.

<ymaps:GeoObject>    <gml:name>Point on map</gml:name>    <gml:description>Billy was here</gml:description>    <gml:Point>        <gml:pos>-119.755992 34.406958</gml:pos>    </gml:Point></ymaps:GeoObject>

Example in the sandbox

Polyline and closed polyline

To set the points of a polyline, either two or more gml:pos elements or the gml:posList element can be used.

<ymaps:GeoObject>
    <gml:name>Polyline</gml:name>
    <gml:description>Polyline point coordinates can be set using two or more  elements gml:pos</gml:description>
    <gml:LineString>
        <gml:pos>32.199411 58.601185</gml:pos>
        <gml:pos>32.189411 58.595185</gml:pos>
    </gml:LineString>
</ymaps:GeoObject>

Example in the sandbox

<ymaps:GeoObject>
    <gml:name>Closed polyline</gml:name>
    <gml:description>Polyline point coordinates can also be set using the element gml:posList</gml:description>
    <gml:LinearRing>
        <gml:posList>37.178027 55.486953 38.040535 55.486953 38.040535 56.018499 37.178027 56.018499</gml:posList>
    </gml:LinearRing>
</ymaps:GeoObject>

Example in the sandbox

Polygon

The exterior boundary of a polygon consists of a closed polyline, which is described using the gml:LinearRing element.

<ymaps:GeoObject>
    <gml:name>Polygon</gml:name>
    <gml:description>The exterior boundary of the polygon is a closed polyline</gml:description>
    <gml:Polygon>
        <gml:exterior>
            <gml:LinearRing>
                <gml:posList>37.178027 55.486953 38.040535 55.486953 38.040535 56.018499 37.178027 56.018499</gml:posList>
            </gml:LinearRing>
        </gml:exterior>
    </gml:Polygon>
</ymaps:GeoObject>

In this example, the gml: LinearRing element is located inside the gml:exterior container. This reflects the fact that a polygon can have not only an exterior edge, but an interior edge as well (a "hole" inside the polygon). In addition, the number of interior holes is unlimited.

The interior boundary of a polygon is also set using a closed polyline. The gml: LinearRing element is placed in the gml: interior container. In the current version of the Yandex.Maps API, the contents of the gml:interior element are not interpreted. A feature for processing interior edges of polygons is planned for one of the upcoming versions of the API.

Example in the sandbox