2

目印付きの yandex マップを作成します。目印については、次のプリセットを使用します。

'islands#blueHomeIcon'

目印アイコンのサイズを設定する必要があります:

268ピクセル×268ピクセル

私を助けてください。

私の試み:

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:標準の目印アイコンを使用する必要があります(カスタム画像ではありません)

4

1 に答える 1

2

iconImageSizeプロパティを使用するには、レイアウトdefault#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

于 2018-10-22T22:48:53.130 に答える