Adding placemarks with various options and content to the ObjectManager
ObjectManager accepts placemark descriptions in JSON format so you can specify geo object options and data.
index.html
object_manager_options.js
<!DOCTYPE html>
<html>
<head>
<title>
Examples. Adding placemarks with various options and content to
the ObjectManager
</title>
<meta
http-equiv="Content-Type"
content="text/html; charset=UTF-8"
/>
<script
src="https://api-maps.yandex.ru/2.1/?lang=en_RU&apikey=<your API-key>"
type="text/javascript"
></script>
<script
src="https://yandex.st/jquery/2.2.3/jquery.min.js"
type="text/javascript"
></script>
<!-- Note that if you want to add placemarks with glyph icons to the map, you'll need to include Bootstrap-->
<!--
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/
-->
<link
rel="stylesheet"
type="text/css"
href="https://yastatic.net/bootstrap/3.3.4/css/bootstrap.min.css"
/>
<script
src="object_manager_options.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() {
var myMap = new ymaps.Map(
"map",
{
center: [55.76, 37.64],
zoom: 10,
},
{
searchControlProvider: "yandex#search",
}
),
objectManager = new ymaps.ObjectManager();
myMap.geoObjects.add(objectManager);
$.ajax({
// The data.json file describes geometry, options and contents of placemarks.
url: "data.json",
}).done(function (data) {
objectManager.add(data);
});
}