Browse Source

fix for preloading maps tiles

main
Marco Colia 3 years ago
parent
commit
dc102a975f
  1. 41
      assets/leaflet.edgebuffer.js
  2. 2
      js/dist/forum.js
  3. 2
      js/dist/forum.js.map
  4. 7
      js/src/forum/index.js

41
assets/leaflet.edgebuffer.js

@ -0,0 +1,41 @@
(function (factory, window) {
// define an AMD module that relies on 'leaflet'
if (typeof define === 'function' && define.amd) {
define(['leaflet'], factory);
// define a Common JS module that relies on 'leaflet'
} else if (typeof exports === 'object') {
module.exports = factory(require('leaflet'));
}
// attach your plugin to the global 'L' variable
if (typeof window !== 'undefined' && window.L && !window.L.EdgeBuffer) {
factory(window.L);
}
}(function (L) {
L.EdgeBuffer = {
previousMethods: {
getTiledPixelBounds: L.GridLayer.prototype._getTiledPixelBounds
}
};
L.GridLayer.include({
_getTiledPixelBounds : function(center, zoom, tileZoom) {
var pixelBounds = L.EdgeBuffer.previousMethods.getTiledPixelBounds.call(this, center, zoom, tileZoom);
// Default is to buffer one tiles beyond the pixel bounds (edgeBufferTiles = 1).
var edgeBufferTiles = 1;
if ((this.options.edgeBufferTiles !== undefined) && (this.options.edgeBufferTiles !== null)) {
edgeBufferTiles = this.options.edgeBufferTiles;
}
if (edgeBufferTiles > 0) {
var pixelEdgeBuffer = L.GridLayer.prototype.getTileSize.call(this).multiplyBy(edgeBufferTiles);
pixelBounds = new L.Bounds(pixelBounds.min.subtract(pixelEdgeBuffer), pixelBounds.max.add(pixelEdgeBuffer));
}
return pixelBounds;
}
});
}, window));

2
js/dist/forum.js vendored

File diff suppressed because one or more lines are too long

2
js/dist/forum.js.map vendored

File diff suppressed because one or more lines are too long

7
js/src/forum/index.js

@ -11,6 +11,13 @@ app.initializers.add('justoverclock/users-map-location', () => {
User.prototype.location = Model.attribute('location'); User.prototype.location = Model.attribute('location');
extend(UserCard.prototype, 'oncreate', function () { extend(UserCard.prototype, 'oncreate', function () {
let script = document.createElement('script');
script.type = 'text/javascript';
script.src = app.forum.attribute('baseUrl') + '/assets/extensions/justoverclock-users-map-location/leaflet.edgebuffer.js'
document.head.appendChild(script);
const user = this.attrs.user; const user = this.attrs.user;
let UserLocation = user.location(); let UserLocation = user.location();
const publicToken = app.forum.attribute('justoverclock-users-map-location.mapBox-api-key'); const publicToken = app.forum.attribute('justoverclock-users-map-location.mapBox-api-key');

Loading…
Cancel
Save