Changing the balloon content template.
Templates allow you to make custom HTML representations of geo objects, balloons, and hints.
To define a template, use the repr:Representation element, which contains the HTML code (the template body) in the repr:text container.
For more information about templates, see the documentation.
index.html
ymapsml_ballooncontentstyle.js
<!DOCTYPE html>
<html>
<head>
<title>
YMapsML examples. Changing the balloon content template.
</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_ballooncontentstyle.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: [55.76, 37.64],
zoom: 10,
},
{
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);
}
);
}