Answer the question
In order to leave comments, you need to log in
How to put your icon on Yandex maps?
Hello, I can’t figure out how to put my icons on the labels. I clustered the labels, made icons on the clusters themselves, but it doesn’t work on the labels.
<script>
ymaps.ready(function () {
var myMap = new ymaps.Map('map', {
center: [55.751574, 37.573856],
zoom: 12
}, {
searchControlProvider: 'yandex#search'
}),
clusterer = new ymaps.Clusterer({
clusterIcons: [
{
href: '/assets/img/logo.png',
size: [20, 45],
offset: [-3, -42]
},
{
href: '/assets/img/logo.png',
size: [20, 45],
offset: [-3, -42]
}],
clusterNumbers: [10],
clusterIconContentLayout: null
}),
getPointData = function (index) {
return {
iconLayout: 'default#image',
iconImageHref: '/assets/img/logo.png',
iconImageSize: [70, 70],
iconImageOffset: [-35, -35]
};
},
points = [
[55.691846,37.568841],[55.812949,37.650162],[55.907869,37.582933],[55.749491,37.591421],[55.801415,37.531774],[55.878076,37.559649]
],
geoObjects = [];
for (var i = 0, len = points.length; i < len; i++) {
geoObjects[i] = new ymaps.Placemark(points[i], getPointData(points[i]));
}
clusterer.add(geoObjects);
myMap.geoObjects.add(clusterer);
myMap.setBounds(clusterer.getBounds(), {
checkZoomRange: true
});
myMap.behaviors.disable('scrollZoom');
});
</script>
Answer the question
In order to leave comments, you need to log in
Everything should have been written like this
for (var i = 0, len = points.length; i < len; i++) {
geoObjects[i] = new ymaps.Placemark(points[i], {
balloonContentBody: '',
},{
iconLayout: 'default#image',
iconImageHref: '/assets/img/logo.png',
iconImageSize: [20, 45],
iconImageOffset: [-3, -42],
});
}
https://yandex.ru/blog/mapsapi/46712
https://yandex.ru/blog/mapsapi/36471
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question