2

I make yandex map with placemark. For placemark i use follow preset:

'islands#blueHomeIcon'

I need set size for placemark icon:

268px x 268px

Please help me.

My try:

let map;
let latitude = 55.8005930;
let longitude = 49.2119510;
let zoom = 16;
let controls = ['fullscreenControl', 'rulerControl'];


ymaps.ready().then(() => {
  map = new ymaps.Map('map', {
    center: [latitude, longitude],
    zoom: zoom,
    controls: controls
  });

  setMarker([latitude, longitude]);
});

function setMarker(coords) {
  const marker = new ymaps.Placemark(coords, {}, {
    preset: 'islands#blueHomeIcon',
    iconImageSize: [268, 268]
  });

  map.geoObjects.add(marker);
}

JSFIDDLE

UPD: i need use standart placemark icon (not custom image)

ptortyr45
  • 147
  • 1
  • 11

1 Answers1

2

To use iconImageSize property it seems you have to use layout default#image and provide your image.

myPlacemark = new ymaps.Placemark(myMap.getCenter(), {
        hintContent: 'A custom placemark icon',
        balloonContent: 'This is a pretty placemark'
    }, {
        /**
         * Options.
         * You must specify this type of layout.
         */
        iconLayout: 'default#image',
        // Custom image for the placemark icon.
        iconImageHref: 'images/myIcon.gif',
        // The size of the placemark.
        iconImageSize: [30, 42],
        /**
         * The offset of the upper left corner of the icon relative
         * to its "tail" (the anchor point).
         */
        iconImageOffset: [-5, -38]
    }),

https://tech.yandex.com/maps/jsbox/2.1/icon_customImage

Niloct
  • 9,491
  • 3
  • 44
  • 57