Skip to content

Commit

Permalink
Merge pull request #12 from lipton-ice-tea/1.0.7
Browse files Browse the repository at this point in the history
1.0.7
  • Loading branch information
lipton-ice-tea authored Jul 5, 2021
2 parents 7159973 + c20806e commit d9f57c4
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/images/arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
coordinates: L.latLng(51.495, -0.06),
prevLatlng: L.latLng(51.503, -0.09),
img: './images/arrow.svg',
imgSize: [40, 40],
imgSize: [50, 50],
priority: 2,
},
];
Expand Down Expand Up @@ -103,12 +103,12 @@
case 'img':
const coordinatesPopup = '[' + point.coordinates.lat + ',' + point.coordinates.lng + ']';
L.canvasMarker(point.coordinates, {
radius: 20,
prevLatlng: point.prevLatlng,
img: {
url: point.img,
size: point.imgSize,
rotate: point.imgRotate || 0,
offset: point.offset || { x: 0, y: 0 },
},
}).bindPopup(coordinatesPopup).addTo(map);
break;
Expand Down
11 changes: 9 additions & 2 deletions docs/leaflet-canvas-markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@
},
});

L.canvasMarker = function (...options) {
return new CanvasMarker(...options);
L.canvasMarker = function (...opt) {
try {
const i = opt.findIndex(o => typeof o === 'object' && o.img);
if (i+1) {
if (!opt[i].radius && opt[i].img && opt[i].img.size) opt[i].radius = Math.ceil(Math.max(...opt[i].img.size)/2);
if (opt[i].pane) delete opt[i].pane;
}
} catch(e) {}
return new CanvasMarker(...opt);
};
}));
2 changes: 1 addition & 1 deletion example/images/arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
coordinates: L.latLng(51.495, -0.06),
prevLatlng: L.latLng(51.503, -0.09),
img: './images/arrow.svg',
imgSize: [40, 40],
imgSize: [50, 50],
priority: 2,
},
];
Expand Down Expand Up @@ -103,12 +103,12 @@
case 'img':
const coordinatesPopup = '[' + point.coordinates.lat + ',' + point.coordinates.lng + ']';
L.canvasMarker(point.coordinates, {
radius: 20,
prevLatlng: point.prevLatlng,
img: {
url: point.img,
size: point.imgSize,
rotate: point.imgRotate || 0,
offset: point.offset || { x: 0, y: 0 },
},
}).bindPopup(coordinatesPopup).addTo(map);
break;
Expand Down
11 changes: 9 additions & 2 deletions leaflet-canvas-markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@
},
});

L.canvasMarker = function (...options) {
return new CanvasMarker(...options);
L.canvasMarker = function (...opt) {
try {
const i = opt.findIndex(o => typeof o === 'object' && o.img);
if (i+1) {
if (!opt[i].radius && opt[i].img && opt[i].img.size) opt[i].radius = Math.ceil(Math.max(...opt[i].img.size)/2);
if (opt[i].pane) delete opt[i].pane;
}
} catch(e) {}
return new CanvasMarker(...opt);
};
}));
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leaflet-canvas-markers",
"version": "1.0.6",
"version": "1.0.7",
"description": "Adding all images to one canvas, together with the base L.CircleMarker! And you can create a direction arrow just by pointing to the previous waypoint.",
"main": "leaflet-canvas-markers.js",
"scripts": {
Expand Down

0 comments on commit d9f57c4

Please sign in to comment.