Closed polyline
YMapsML is a language for describing geographical objects.
In YMapsML, each geographical object is associated with a geometric shape and a geo object that is used for displaying this shape on the map. The shape definitions and their anchors to geographical coordinates are set in corresponding YMapsML elements. The gml:LinearRing element is designated for the "linear ring" shape. This element contains the coordinates of line endpoints. The coordinates of the first and last endpoints must match.
The visual appearance of displayed objects is set in the repr:Representation element. For detailed instructions on setting styles for displayed objects, see the documentation.
The geoXml.load function is used for loading YMapsML data. After data loads, the function converts it to GeoObjectCollection and passes it to the handler function as a parameter. A GeoObjectCollection can be displayed on the map.
<!DOCTYPE html>
<html>
<head>
<title>YMapsML examples. Polyline.</title>
<meta
http-equiv="Content-Type"
content="text/html; charset=UTF-8"
/>
<!--
Set your own API-key. Testing key is not valid for other web-sites and services.
Get your API-key on the Developer Dashboard: https://developer.tech.yandex.ru/keys/
-->
<script
src="https://api-maps.yandex.ru/2.1/?lang=en_RU&apikey=<your API-key>"
type="text/javascript"
></script>
<script src="ymapsml_linearring.js" type="text/javascript"></script>
<style>
html,
body,
#map {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<div id="map"></div>
</body>
</html>
ymaps.ready(init);
function init() {
// Creating an instance of the map.
var myMap = new ymaps.Map(
"map",
{
center: [56.007941, 92.998135],
zoom: 11,
},
{
searchControlProvider: "yandex#search",
}
);
// Loading a YMapsML file.
ymaps.geoXml.load("data.xml").then(
function (res) {
// Adding geo objects to the map.
myMap.geoObjects.add(res.geoObjects);
// Called if loading the YMapsML file was unsuccessful.
},
function (error) {
alert("Error: " + error);
}
);
}