Answer the question
In order to leave comments, you need to log in
How to make a label link to Yandex.maps?
There is an array of labels from which one is selected depending on the page and zoomed.
var data = {
"link1.html": {
"copy24": { "coordinates" : [55.777661543155415,37.5168805], "hintContent": "Точка 1", "iconImageHref": "images/c90.png", "iconImageSize": [64, 64], "iconImageOffset": [-41, -64]},
"zoom": 17
},
"link.html": {
"copy24": { "coordinates" : [55.731935453412873,37.664206356483405], "hintContent": "Точка 2", "iconImageHref": "images/c90.png", "iconImageSize": [64, 64], "iconImageOffset": [-41, -64]},
"zoom": 17
},
"link3.html": {
"copy24": { "coordinates" : [55.7388954008964,37.652793166650504], "hintContent": "Точка 3", "iconImageHref": "images/c90.png", "iconImageSize": [64, 64], "iconImageOffset": [-41, -64]},
"zoom": 17
},
};
var loc = window.location.pathname.split('/');
ymaps.ready(function () {
var myMap = new ymaps.Map('map', {
center: data[loc[loc.length-1]].copy24.coordinates,
zoom: data[loc[loc.length-1]].zoom
}, {
searchControlProvider: 'yandex#search'
}),
clusterer = new ymaps.Clusterer({
// Зададим массив, описывающий иконки кластеров разного размера.
clusterIcons: [{
href: 'images/c3.png',
size: [64, 64],
offset: [-30, -74]
}],
// Эта опция отвечает за размеры кластеров.
// В данном случае для кластеров, содержащих до 100 элементов,
// будет показываться маленькая иконка. Для остальных - большая.
clusterNumbers: [100],
clusterIconContentLayout: null,
maxZoom: 0,
gridSize: 128
}),
geoObjects = [];
for (var element in data) {
geoObjects.push(new ymaps.Placemark(data[element].copy24.coordinates, {
hintContent: data[element].copy24.hintContent,
}, {
iconLayout: 'default#image',
iconImageHref: data[element].copy24.iconImageHref,
iconImageSize: data[element].copy24.iconImageSize,
iconImageOffset: data[element].copy24.iconImageOffset
}));
if (undefined !== data[element].near) {
geoObjects.push(new ymaps.Placemark(data[element].near.coordinates, {
hintContent: data[element].near.hintContent,
}, {
iconLayout: 'default#image',
iconImageHref: data[element].near.iconImageHref,
iconImageSize: data[element].near.iconImageSize,
iconImageOffset: data[element].near.iconImageOffset
}));
}
};
clusterer.add(geoObjects);
myMap.geoObjects.add(clusterer);
myMap.behaviors.disable('scrollZoom');
});
Answer the question
In order to leave comments, you need to log in
If I understand you correctly, then take a look at how a click on a label works in a cluster:
https://tech.yandex.ru/maps/jsbox/2.1/clusterer_ba...
I guess what you could insert window.location.href="новая_ссылка"
in a block
...
getPointData = function (index) {
return {
balloonContentBody: 'балун <strong>метки ' + index + '</strong>',
clusterCaption: 'метка <strong>' + index + '</strong>'
};
},
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question