Skip to content

Commit

Permalink
Merge pull request #81 from johnd0e/leaflet-icon-default
Browse files Browse the repository at this point in the history
leaflet: extend L.Icon.Default in more clean way
  • Loading branch information
modos189 committed Mar 13, 2019
2 parents d77562b + e496e12 commit 9aac3c2
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 20 deletions.
16 changes: 6 additions & 10 deletions code/boot.js
Expand Up @@ -599,16 +599,12 @@ function boot() {
if(window.deviceID) console.log('Your device ID: ' + window.deviceID);
window.runOnSmartphonesBeforeBoot();

var iconDefImage = '@@INCLUDEIMAGE:images/marker-icon.png@@';
var iconDefRetImage = '@@INCLUDEIMAGE:images/marker-icon-2x.png@@';

L.Icon.Default = L.Icon.extend({options: {
iconUrl: iconDefImage,
iconRetinaUrl: iconDefRetImage,
iconSize: new L.Point(25, 41),
iconAnchor: new L.Point(12, 41),
popupAnchor: new L.Point(1, -34),
}});
L.Icon.Default.mergeOptions({
iconUrl: '@@INCLUDEIMAGE:images/marker-ingress.png@@',
iconRetinaUrl: '@@INCLUDEIMAGE:images/marker-ingress-2x.png@@',
shadowUrl: '@@INCLUDEIMAGE:images/marker-shadow.png@@'
});
L.Icon.Default.imagePath = ' '; // in order to suppress _detectIconPath (it fails with data-urls)

window.extractFromStock();
window.setupIdle();
Expand Down
4 changes: 2 additions & 2 deletions external/leaflet.css
Expand Up @@ -463,8 +463,8 @@
}

/* Default icon URLs */
.leaflet-default-icon-path {
background-image: url(@@INCLUDEIMAGE:images/marker-icon.png@@);
.leaflet-default-icon-path { /* IITC: Is's dummy style used in Icon.Default._detectIconPath */
background-image: url(images/marker-icon.png); /* IITC: No need to patch it here */
}

/* attribution and scale controls */
Expand Down
Binary file modified images/marker-icon-2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/marker-icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/marker-ingress-2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/marker-ingress.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/marker-shadow.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 6 additions & 8 deletions plugins/add-kml.user.js
Expand Up @@ -88,14 +88,12 @@ var _fileLayerLoad = null;
window.plugin.overlayKML.load = function() {
// Provide popup window allow user to select KML to overlay

L.Icon.Default.imagePath = '@@INCLUDEIMAGE:images/marker-icon.png@@';
var KMLIcon = L.icon({
iconUrl: '@@INCLUDEIMAGE:images/marker-icon.png@@',

iconSize: [16, 24], // size of the icon
iconAnchor: [8, 24], // point of the icon which will correspond to marker's location
popupAnchor: [-3, 16] // point from which the popup should open relative to the iconAnchor
});
var KMLIcon = L.icon(L.extend({},L.Icon.Default.prototype.options,{
iconSize: [16, 24],
iconAnchor: [8, 24],
popupAnchor: [-3, 16],
shadowSize: [24, 24]
}));

L.Control.FileLayerLoad.LABEL = '<img src="@@INCLUDEIMAGE:images/open-folder-icon_sml.png@@" alt="Open" />';
_fileLayerLoad = L.Control.fileLayerLoad({
Expand Down

0 comments on commit 9aac3c2

Please sign in to comment.