Add custom marker icon images

This commit is contained in:
Emanuel Mutschlechner
2020-01-06 19:05:16 +01:00
parent 4c9f08f229
commit 0650921c2f
18 changed files with 3676 additions and 2916 deletions

View File

@@ -21,11 +21,26 @@ export default {
return map;
},
createMarker(map, markerData) {
const {title, lat, lng, url} = markerData;
const {title, lat, lng, url, icon, iconSize, iconAnchor} = markerData;
const marker = new window.ymaps.Placemark([lat, lng], {
const placemarkProperties = {
hintContent: title,
});
};
const placemarkOptions = {};
if (icon) {
placemarkOptions.iconLayout = 'default#imageWithContent';
placemarkOptions.iconImageHref = icon;
if (iconSize) {
placemarkOptions.iconImageSize = iconSize;
}
if (iconAnchor) {
placemarkOptions.iconImageOffset = iconAnchor;
}
}
const marker = new window.ymaps.Placemark([lat, lng], placemarkProperties, placemarkOptions);
// if (url) {
// marker.addListener('click', () => {
@@ -34,5 +49,7 @@ export default {
// }
map.geoObjects.add(marker);
return marker;
},
};