我用地标制作yandex地图。对于我使用的地标,请遵循以下预设:
'islands#blueHomeIcon'
我需要为地标图标设置大小:
268px x 268px
请帮助我。
我的尝试:
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);
}
UPD:我需要使用标准地标图标(不是自定义图片)
答案 0 :(得分: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]
}),