SK
Size: a a a
SK
SK
A
SK
SK
<Marker><div onClick={this.click} /></Marker>A
A
A
A
A
export function ImageLoader({ id, image }) {
const svgPathToImage = ({ path, width, height }) => new Promise(resolve => {
const image = new Image(width, height);
image.addEventListener('load', () => resolve(image));
image.setAttribute('crossOrigin', '');
image.src = path;
});
const [rasterImage, setRasterImage] = useState();
useEffect(() => {
if (image) svgPathToImage({ path: image, width: 15, height: 15 }).then(setRasterImage);
}, [image]);
return rasterImage ? <UrbicaImage id={id} image={rasterImage} /> : null;
}DS
A
DS
DS
A
A
A
DS
DS
export const addImage = (type, map) => {
const rgb = colors[type];
const canvasEl = document.createElement('canvas');
canvasEl.width = width;
canvasEl.height = height;
const context = canvasEl.getContext('2d');
const radius = (size / 2) * 0.3;
const outerRadius = (size / 2) * 0.7 * 1 + radius;
context.clearRect(0, 0, width, height);
context.beginPath();
context.arc(width / 2, height / 2, outerRadius, 0, Math.PI * 2);
context.fillStyle = `rgba(${rgb.join(',')}, 0.3)`;
context.fill();
const data = context.getImageData(0, 0, width, height).data;
map.addImage(prefix + type, { width: width, height: width, data: data });
};DS