Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Добавляем метод в канву, который рисует картинку
- L.Canvas.include({
- _updateImg: function(layer) {
- let p = layer._point.round(),
- img = layer.options.imgEl,
- imgSize = layer.options.imgSize;
- this._ctx.drawImage(img, p.x - imgSize[0] / 2, p.y - imgSize[1] / 2, imgSize[0], imgSize[1]);
- }
- });
- //Расширяем стандартный класс
- const customCircleMarker = L.CircleMarker.extend({
- _updatePath: function () {
- if (!this.options.imgEl) {
- let img = document.createElement('img');
- img.src = this.options.img;
- this.options.imgEl = img;
- img.onload = () => {
- this.redraw();
- }
- } else {
- this._renderer._updateImg(this);
- }
- }
- });
- //Используем расширенный класс
- return new customCircleMarker(latlng, {
- img: '/img/test.svg',
- imgSize: [32, 34],
- radius: 16,
- telemetryId: feature.properties.telemetryId,
- fillColor: '#fff',
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement