Converting GeoRSS to YMapsML
The YMapsML displayed on the map (see the ymapsml.xml file) was automatically generated using XSLT, from the data that was originally presented in GeoRSS format (see georss.xml). The conversion template is in the georsstoymapsm_xsl.xml file.
index.html
ymapsml_georss.js
<!DOCTYPE html>
<html>
<head>
<title>Examples. Converting GeoRSS to YMapsML.</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_georss.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: [50.76, 35.64],
zoom: 0,
},
{
searchControlProvider: "yandex#search",
}
);
// Loading a YMapsML file.
ymaps.geoXml.load("ymapsml.xml").then(
function (res) {
myMap.geoObjects.add(res.geoObjects);
},
// Called if loading the YMapsML file was unsuccessful.
function (error) {
alert(
"When loading the YMapsML file, the following error occurred: " +
error
);
}
);
}