Skip to content

Commit

Permalink
Extracted leaflet monkey patching #3
Browse files Browse the repository at this point in the history
  • Loading branch information
modos189 committed Jan 18, 2019
1 parent 953519d commit 551f4c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
29 changes: 19 additions & 10 deletions code/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,24 @@ window.setupLayerChooserApi = function() {
}
}

function MonkeyPatching_Leaflet() {
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)
},
_getIconUrl: function (name) {
return L.Icon.prototype._getIconUrl.call(this, name);
}
});
}

// BOOTING ///////////////////////////////////////////////////////////

function boot() {
Expand All @@ -599,16 +617,7 @@ 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),
}});
MonkeyPatching_Leaflet();

window.extractFromStock();
window.setupIdle();
Expand Down
2 changes: 1 addition & 1 deletion external/leaflet.css
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@

/* Default icon URLs */
.leaflet-default-icon-path {
background-image: url(@@INCLUDEIMAGE:images/marker-icon.png@@);
background-image: url(""); /* requires Path: not URL! Patched in Boot */
}

/* attribution and scale controls */
Expand Down

0 comments on commit 551f4c9

Please sign in to comment.