| 1234567891011121314151617181920212223242526272829303132333435 |
- // leaflet 补丁
- // author: wzx
- // version: 1.0
- export default {
- run() {
- this.patchIconPath()
- this.patchTileWhiteLine()
- },
- // 解决leaflet默认图标的路径错误问题
- patchIconPath() {
- delete L.Icon.Default.prototype._getIconUrl
- L.Icon.Default.mergeOptions({
- iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png'),
- iconUrl: require('leaflet/dist/images/marker-icon.png'),
- shadowUrl: require('leaflet/dist/images/marker-shadow.png')
- })
- },
- // 解决leaflet瓦片显示有白线问题
- patchTileWhiteLine() {
- (function() {
- var originalInitTile = L.GridLayer.prototype._initTile
- L.GridLayer.include({
- _initTile: function(tile) {
- originalInitTile.call(this, tile);
-
- var tileSize = this.getTileSize();
-
- tile.style.width = tileSize.x + 1 + 'px';
- tile.style.height = tileSize.y + 1 + 'px';
- }
- });
- })()
- }
- }
|