Answer the question
In order to leave comments, you need to log in
How to load new tags in Yandex.Maps?
There are several sets of labels packaged in separate JSON files.
At the request of the user, it is necessary to display the set of labels he needs.
Right now I've implemented it with links on the page:
<a href="#" onclick="init();">Hey!</a>
<a href="#" onclick="init2();">Hey!</a>
<a href="#" onclick="init3();">Hey!</a>
function init () {
$("ymaps").remove();
var myMap = new ymaps.Map('map', {
center: [55.76, 37.64],
zoom: 10,
controls: ['zoomControl']
}, {
searchControlProvider: 'yandex#search'
}),
objectManager = new ymaps.ObjectManager({
clusterize: true,
gridSize: 32
});
objectManager.objects.options.set('preset', 'islands#darkGreenCircleDotIcon');
objectManager.clusters.options.set('preset', 'islands#invertedDarkGreenClusterIcons');
myMap.geoObjects.add(objectManager);
$.ajax({
url: "1.json"
}).done(function(data) {
objectManager.add(data);
});
}
ymaps.ready(init);
var myMap;
function init () {
myMap = new ymaps.Map('map', {
center: [55.76, 37.64],
zoom: 11,
controls: ['zoomControl']
}, {
searchControlProvider: 'yandex#search'
}),
objectManager = new ymaps.ObjectManager({
clusterize: true,
gridSize: 32
});
objectManager.objects.options.set('preset', 'islands#darkGreenCircleDotIcon');
objectManager.clusters.options.set('preset', 'islands#invertedDarkGreenClusterIcons');
myMap.geoObjects.add(objectManager);
$.ajax({
url: "1.json"
}).done(function(data) {
objectManager.add(data);
});
}
function newpins () {
if(myMap)
myMap.geoObjects.removeAll();
objectManager = new ymaps.ObjectManager({
clusterize: true,
gridSize: 32
});
objectManager.objects.options.set('preset', 'islands#darkGreenCircleDotIcon');
objectManager.clusters.options.set('preset', 'islands#invertedDarkGreenClusterIcons');
myMap.geoObjects.add(objectManager);
$.ajax({
url: "4.json"
}).done(function(data) {
objectManager.add(data);
});
}
Answer the question
In order to leave comments, you need to log in
about
var myMap = new ymaps.Map('map', {
center: [55.76, 37.64],
zoom: 10,
controls: ['zoomControl']
}, {
searchControlProvider: 'yandex#search'
});
function init () {
if(myMap)
myMap.geoObjects.removeAll();
objectManager = new ymaps.ObjectManager({
clusterize: true,
gridSize: 32
});
objectManager.objects.options.set('preset', 'islands#darkGreenCircleDotIcon');
objectManager.clusters.options.set('preset', 'islands#invertedDarkGreenClusterIcons');
myMap.geoObjects.add(objectManager);
$.ajax({
url: "1.json"
}).done(function(data) {
objectManager.add(data);
});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question