@asymmetrik/ngx-leaflet
Advanced tools
Comparing version 3.1.0 to 4.0.0
@@ -1,205 +0,186 @@ | ||
/*! @asymmetrik/ngx-leaflet - 3.1.0 - Copyright Asymmetrik, Ltd. 2007-2018 - All Rights Reserved. + */ | ||
/*! @asymmetrik/ngx-leaflet - 4.0.0 - Copyright Asymmetrik, Ltd. 2007-2018 - All Rights Reserved. + */ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('leaflet')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'leaflet'], factory) : | ||
(factory((global.ngxLeaflet = {}),global.ng.core,global.L)); | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('leaflet')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'leaflet'], factory) : | ||
(factory((global.ngxLeaflet = {}),global.ng.core,global.L)); | ||
}(this, (function (exports,core,leaflet) { 'use strict'; | ||
var LeafletUtil = /** @class */ (function () { | ||
function LeafletUtil() { | ||
} | ||
LeafletUtil.mapToArray = function (map$$1) { | ||
var toReturn = []; | ||
for (var k in map$$1) { | ||
if (map$$1.hasOwnProperty(k)) { | ||
toReturn.push(map$$1[k]); | ||
var LeafletUtil = /** @class */ (function () { | ||
function LeafletUtil() { | ||
} | ||
LeafletUtil.mapToArray = function (map) { | ||
var toReturn = []; | ||
for (var k in map) { | ||
if (map.hasOwnProperty(k)) { | ||
toReturn.push(map[k]); | ||
} | ||
} | ||
return toReturn; | ||
}; | ||
LeafletUtil.handleEvent = function (zone, eventEmitter, event) { | ||
// Don't want to emit if there are no observers | ||
if (0 < eventEmitter.observers.length) { | ||
zone.run(function () { | ||
eventEmitter.emit(event); | ||
}); | ||
} | ||
}; | ||
return LeafletUtil; | ||
}()); | ||
var LeafletDirective = /** @class */ (function () { | ||
function LeafletDirective(element, zone) { | ||
this.element = element; | ||
this.zone = zone; | ||
this.DEFAULT_ZOOM = 1; | ||
this.DEFAULT_CENTER = leaflet.latLng(38.907192, -77.036871); | ||
this.DEFAULT_FPZ_OPTIONS = {}; | ||
this.fitBoundsOptions = this.DEFAULT_FPZ_OPTIONS; | ||
this.panOptions = this.DEFAULT_FPZ_OPTIONS; | ||
this.zoomOptions = this.DEFAULT_FPZ_OPTIONS; | ||
this.zoomPanOptions = this.DEFAULT_FPZ_OPTIONS; | ||
// Default configuration | ||
this.options = {}; | ||
// Configure callback function for the map | ||
this.mapReady = new core.EventEmitter(); | ||
this.zoomChange = new core.EventEmitter(); | ||
this.centerChange = new core.EventEmitter(); | ||
// Mouse Map Events | ||
this.onClick = new core.EventEmitter(); | ||
this.onDoubleClick = new core.EventEmitter(); | ||
this.onMouseDown = new core.EventEmitter(); | ||
this.onMouseUp = new core.EventEmitter(); | ||
this.onMouseMove = new core.EventEmitter(); | ||
this.onMouseOver = new core.EventEmitter(); | ||
// Map Move Events | ||
this.onMapMove = new core.EventEmitter(); | ||
this.onMapMoveStart = new core.EventEmitter(); | ||
this.onMapMoveEnd = new core.EventEmitter(); | ||
// Map Zoom Events | ||
this.onMapZoom = new core.EventEmitter(); | ||
this.onMapZoomStart = new core.EventEmitter(); | ||
this.onMapZoomEnd = new core.EventEmitter(); | ||
// Nothing here | ||
} | ||
return toReturn; | ||
}; | ||
LeafletUtil.handleEvent = function (zone, eventEmitter, event) { | ||
// Don't want to emit if there are no observers | ||
if (0 < eventEmitter.observers.length) { | ||
zone.run(function () { | ||
eventEmitter.emit(event); | ||
LeafletDirective.prototype.ngOnInit = function () { | ||
var _this = this; | ||
// Create the map outside of angular so the various map events don't trigger change detection | ||
this.zone.runOutsideAngular(function () { | ||
// Create the map with some reasonable defaults | ||
_this.map = leaflet.map(_this.element.nativeElement, _this.options); | ||
_this.addMapEventListeners(); | ||
}); | ||
} | ||
}; | ||
return LeafletUtil; | ||
}()); | ||
var LeafletDirective = /** @class */ (function () { | ||
function LeafletDirective(element, zone) { | ||
// Nothing here | ||
this.element = element; | ||
this.zone = zone; | ||
this.DEFAULT_ZOOM = 1; | ||
this.DEFAULT_CENTER = leaflet.latLng(38.907192, -77.036871); | ||
this.DEFAULT_FPZ_OPTIONS = {}; | ||
this.fitBoundsOptions = this.DEFAULT_FPZ_OPTIONS; | ||
this.panOptions = this.DEFAULT_FPZ_OPTIONS; | ||
this.zoomOptions = this.DEFAULT_FPZ_OPTIONS; | ||
this.zoomPanOptions = this.DEFAULT_FPZ_OPTIONS; | ||
// Default configuration | ||
this.options = {}; | ||
// Configure callback function for the map | ||
this.mapReady = new core.EventEmitter(); | ||
this.zoomChange = new core.EventEmitter(); | ||
this.centerChange = new core.EventEmitter(); | ||
// Mouse Map Events | ||
this.onClick = new core.EventEmitter(); | ||
this.onDoubleClick = new core.EventEmitter(); | ||
this.onMouseDown = new core.EventEmitter(); | ||
this.onMouseUp = new core.EventEmitter(); | ||
this.onMouseMove = new core.EventEmitter(); | ||
this.onMouseOver = new core.EventEmitter(); | ||
// Map Move Events | ||
this.onMapMove = new core.EventEmitter(); | ||
this.onMapMoveStart = new core.EventEmitter(); | ||
this.onMapMoveEnd = new core.EventEmitter(); | ||
// Map Zoom Events | ||
this.onMapZoom = new core.EventEmitter(); | ||
this.onMapZoomStart = new core.EventEmitter(); | ||
this.onMapZoomEnd = new core.EventEmitter(); | ||
} | ||
LeafletDirective.prototype.ngOnInit = function () { | ||
var _this = this; | ||
// Create the map outside of angular so the various map events don't trigger change detection | ||
this.zone.runOutsideAngular(function () { | ||
// Create the map with some reasonable defaults | ||
// Create the map with some reasonable defaults | ||
_this.map = leaflet.map(_this.element.nativeElement, _this.options); | ||
_this.addMapEventListeners(); | ||
}); | ||
// Only setView if there is a center/zoom | ||
if (null != this.center && null != this.zoom) { | ||
this.setView(this.center, this.zoom); | ||
} | ||
// Set up all the initial settings | ||
if (null != this.fitBounds) { | ||
this.setFitBounds(this.fitBounds); | ||
} | ||
if (null != this.maxBounds) { | ||
this.setMaxBounds(this.maxBounds); | ||
} | ||
if (null != this.minZoom) { | ||
this.setMinZoom(this.minZoom); | ||
} | ||
if (null != this.maxZoom) { | ||
this.setMaxZoom(this.maxZoom); | ||
} | ||
this.doResize(); | ||
// Fire map ready event | ||
this.mapReady.emit(this.map); | ||
}; | ||
LeafletDirective.prototype.ngOnChanges = function (changes) { | ||
/* | ||
* The following code is to address an issue with our (basic) implementation of | ||
* zooming and panning. From our testing, it seems that a pan operation followed | ||
* by a zoom operation in the same thread will interfere with eachother. The zoom | ||
* operation interrupts/cancels the pan, resulting in a final center point that is | ||
* inaccurate. The solution seems to be to either separate them with a timeout or | ||
* to collapse them into a setView call. | ||
*/ | ||
// Zooming and Panning | ||
if (changes['zoom'] && changes['center'] && null != this.zoom && null != this.center) { | ||
this.setView(changes['center'].currentValue, changes['zoom'].currentValue); | ||
} | ||
else if (changes['zoom']) { | ||
this.setZoom(changes['zoom'].currentValue); | ||
} | ||
else if (changes['center']) { | ||
this.setCenter(changes['center'].currentValue); | ||
} | ||
// Other options | ||
if (changes['fitBounds']) { | ||
this.setFitBounds(changes['fitBounds'].currentValue); | ||
} | ||
if (changes['maxBounds']) { | ||
this.setMaxBounds(changes['maxBounds'].currentValue); | ||
} | ||
if (changes['minZoom']) { | ||
this.setMinZoom(changes['minZoom'].currentValue); | ||
} | ||
if (changes['maxZoom']) { | ||
this.setMaxZoom(changes['maxZoom'].currentValue); | ||
} | ||
}; | ||
LeafletDirective.prototype.getMap = function () { | ||
return this.map; | ||
}; | ||
LeafletDirective.prototype.onResize = function () { | ||
this.delayResize(); | ||
}; | ||
LeafletDirective.prototype.addMapEventListeners = function () { | ||
var _this = this; | ||
// Add all the pass-through mouse event handlers | ||
this.map.on('click', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onClick, e); }); | ||
this.map.on('dblclick', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onDoubleClick, e); }); | ||
this.map.on('mousedown', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMouseDown, e); }); | ||
this.map.on('mouseup', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMouseUp, e); }); | ||
this.map.on('mouseover', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMouseOver, e); }); | ||
this.map.on('mousemove', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMouseMove, e); }); | ||
this.map.on('zoomstart', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMapZoomStart, e); }); | ||
this.map.on('zoom', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMapZoom, e); }); | ||
this.map.on('zoomend', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMapZoomEnd, e); }); | ||
this.map.on('movestart', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMapMoveStart, e); }); | ||
this.map.on('move', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMapMove, e); }); | ||
this.map.on('moveend', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMapMoveEnd, e); }); | ||
// Update any things for which we provide output bindings | ||
this.map.on('zoomend moveend', function () { | ||
var zoom = _this.map.getZoom(); | ||
if (zoom !== _this.zoom) { | ||
_this.zoom = zoom; | ||
LeafletUtil.handleEvent(_this.zone, _this.zoomChange, zoom); | ||
// Only setView if there is a center/zoom | ||
if (null != this.center && null != this.zoom) { | ||
this.setView(this.center, this.zoom); | ||
} | ||
var center = _this.map.getCenter(); | ||
if (null != center || null != _this.center) { | ||
if (((null == center || null == _this.center) && center !== _this.center) | ||
|| (center.lat !== _this.center.lat || center.lng !== _this.center.lng)) { | ||
_this.center = center; | ||
LeafletUtil.handleEvent(_this.zone, _this.centerChange, center); | ||
// Set up all the initial settings | ||
if (null != this.fitBounds) { | ||
this.setFitBounds(this.fitBounds); | ||
} | ||
if (null != this.maxBounds) { | ||
this.setMaxBounds(this.maxBounds); | ||
} | ||
if (null != this.minZoom) { | ||
this.setMinZoom(this.minZoom); | ||
} | ||
if (null != this.maxZoom) { | ||
this.setMaxZoom(this.maxZoom); | ||
} | ||
this.doResize(); | ||
// Fire map ready event | ||
this.mapReady.emit(this.map); | ||
}; | ||
LeafletDirective.prototype.ngOnChanges = function (changes) { | ||
/* | ||
* The following code is to address an issue with our (basic) implementation of | ||
* zooming and panning. From our testing, it seems that a pan operation followed | ||
* by a zoom operation in the same thread will interfere with eachother. The zoom | ||
* operation interrupts/cancels the pan, resulting in a final center point that is | ||
* inaccurate. The solution seems to be to either separate them with a timeout or | ||
* to collapse them into a setView call. | ||
*/ | ||
// Zooming and Panning | ||
if (changes['zoom'] && changes['center'] && null != this.zoom && null != this.center) { | ||
this.setView(changes['center'].currentValue, changes['zoom'].currentValue); | ||
} | ||
else if (changes['zoom']) { | ||
this.setZoom(changes['zoom'].currentValue); | ||
} | ||
else if (changes['center']) { | ||
this.setCenter(changes['center'].currentValue); | ||
} | ||
// Other options | ||
if (changes['fitBounds']) { | ||
this.setFitBounds(changes['fitBounds'].currentValue); | ||
} | ||
if (changes['maxBounds']) { | ||
this.setMaxBounds(changes['maxBounds'].currentValue); | ||
} | ||
if (changes['minZoom']) { | ||
this.setMinZoom(changes['minZoom'].currentValue); | ||
} | ||
if (changes['maxZoom']) { | ||
this.setMaxZoom(changes['maxZoom'].currentValue); | ||
} | ||
}; | ||
LeafletDirective.prototype.getMap = function () { | ||
return this.map; | ||
}; | ||
LeafletDirective.prototype.onResize = function () { | ||
this.delayResize(); | ||
}; | ||
LeafletDirective.prototype.addMapEventListeners = function () { | ||
var _this = this; | ||
// Add all the pass-through mouse event handlers | ||
this.map.on('click', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onClick, e); }); | ||
this.map.on('dblclick', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onDoubleClick, e); }); | ||
this.map.on('mousedown', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMouseDown, e); }); | ||
this.map.on('mouseup', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMouseUp, e); }); | ||
this.map.on('mouseover', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMouseOver, e); }); | ||
this.map.on('mousemove', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMouseMove, e); }); | ||
this.map.on('zoomstart', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMapZoomStart, e); }); | ||
this.map.on('zoom', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMapZoom, e); }); | ||
this.map.on('zoomend', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMapZoomEnd, e); }); | ||
this.map.on('movestart', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMapMoveStart, e); }); | ||
this.map.on('move', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMapMove, e); }); | ||
this.map.on('moveend', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onMapMoveEnd, e); }); | ||
// Update any things for which we provide output bindings | ||
this.map.on('zoomend moveend', function () { | ||
var zoom = _this.map.getZoom(); | ||
if (zoom !== _this.zoom) { | ||
_this.zoom = zoom; | ||
LeafletUtil.handleEvent(_this.zone, _this.zoomChange, zoom); | ||
} | ||
} | ||
}); | ||
}; | ||
/** | ||
* Resize the map to fit it's parent container | ||
*/ | ||
/** | ||
var center = _this.map.getCenter(); | ||
if (null != center || null != _this.center) { | ||
if (((null == center || null == _this.center) && center !== _this.center) | ||
|| (center.lat !== _this.center.lat || center.lng !== _this.center.lng)) { | ||
_this.center = center; | ||
LeafletUtil.handleEvent(_this.zone, _this.centerChange, center); | ||
} | ||
} | ||
}); | ||
}; | ||
/** | ||
* Resize the map to fit it's parent container | ||
*/ | ||
LeafletDirective.prototype.doResize = /** | ||
* Resize the map to fit it's parent container | ||
*/ | ||
function () { | ||
var _this = this; | ||
// Run this outside of angular so the map events stay outside of angular | ||
this.zone.runOutsideAngular(function () { | ||
// Invalidate the map size to trigger it to update itself | ||
// Invalidate the map size to trigger it to update itself | ||
_this.map.invalidateSize({}); | ||
}); | ||
}; | ||
/** | ||
* Manage a delayed resize of the component | ||
*/ | ||
/** | ||
LeafletDirective.prototype.doResize = function () { | ||
var _this = this; | ||
// Run this outside of angular so the map events stay outside of angular | ||
this.zone.runOutsideAngular(function () { | ||
// Invalidate the map size to trigger it to update itself | ||
_this.map.invalidateSize({}); | ||
}); | ||
}; | ||
/** | ||
* Manage a delayed resize of the component | ||
*/ | ||
LeafletDirective.prototype.delayResize = /** | ||
* Manage a delayed resize of the component | ||
*/ | ||
function () { | ||
if (null != this.resizeTimer) { | ||
clearTimeout(this.resizeTimer); | ||
} | ||
this.resizeTimer = setTimeout(this.doResize.bind(this), 200); | ||
}; | ||
/** | ||
* Set the view (center/zoom) all at once | ||
* @param center The new center | ||
* @param zoom The new zoom level | ||
*/ | ||
/** | ||
LeafletDirective.prototype.delayResize = function () { | ||
if (null != this.resizeTimer) { | ||
clearTimeout(this.resizeTimer); | ||
} | ||
this.resizeTimer = setTimeout(this.doResize.bind(this), 200); | ||
}; | ||
/** | ||
* Set the view (center/zoom) all at once | ||
@@ -209,286 +190,226 @@ * @param center The new center | ||
*/ | ||
LeafletDirective.prototype.setView = /** | ||
* Set the view (center/zoom) all at once | ||
* @param center The new center | ||
* @param zoom The new zoom level | ||
*/ | ||
function (center, zoom) { | ||
if (this.map && null != center && null != zoom) { | ||
this.map.setView(center, zoom, this.zoomPanOptions); | ||
} | ||
}; | ||
/** | ||
* Set the map zoom level | ||
* @param zoom the new zoom level for the map | ||
*/ | ||
/** | ||
LeafletDirective.prototype.setView = function (center, zoom) { | ||
if (this.map && null != center && null != zoom) { | ||
this.map.setView(center, zoom, this.zoomPanOptions); | ||
} | ||
}; | ||
/** | ||
* Set the map zoom level | ||
* @param zoom the new zoom level for the map | ||
*/ | ||
LeafletDirective.prototype.setZoom = /** | ||
* Set the map zoom level | ||
* @param zoom the new zoom level for the map | ||
*/ | ||
function (zoom) { | ||
if (this.map && null != zoom) { | ||
this.map.setZoom(zoom, this.zoomOptions); | ||
} | ||
}; | ||
/** | ||
* Set the center of the map | ||
* @param center the center point | ||
*/ | ||
/** | ||
LeafletDirective.prototype.setZoom = function (zoom) { | ||
if (this.map && null != zoom) { | ||
this.map.setZoom(zoom, this.zoomOptions); | ||
} | ||
}; | ||
/** | ||
* Set the center of the map | ||
* @param center the center point | ||
*/ | ||
LeafletDirective.prototype.setCenter = /** | ||
* Set the center of the map | ||
* @param center the center point | ||
*/ | ||
function (center) { | ||
if (this.map && null != center) { | ||
this.map.panTo(center, this.panOptions); | ||
} | ||
}; | ||
/** | ||
* Fit the map to the bounds | ||
* @param latLngBounds the boundary to set | ||
*/ | ||
/** | ||
LeafletDirective.prototype.setCenter = function (center) { | ||
if (this.map && null != center) { | ||
this.map.panTo(center, this.panOptions); | ||
} | ||
}; | ||
/** | ||
* Fit the map to the bounds | ||
* @param latLngBounds the boundary to set | ||
*/ | ||
LeafletDirective.prototype.setFitBounds = /** | ||
* Fit the map to the bounds | ||
* @param latLngBounds the boundary to set | ||
*/ | ||
function (latLngBounds) { | ||
if (this.map && null != latLngBounds) { | ||
this.map.fitBounds(latLngBounds, this.fitBoundsOptions); | ||
} | ||
}; | ||
/** | ||
* Set the map's max bounds | ||
* @param latLngBounds the boundary to set | ||
*/ | ||
/** | ||
LeafletDirective.prototype.setFitBounds = function (latLngBounds) { | ||
if (this.map && null != latLngBounds) { | ||
this.map.fitBounds(latLngBounds, this.fitBoundsOptions); | ||
} | ||
}; | ||
/** | ||
* Set the map's max bounds | ||
* @param latLngBounds the boundary to set | ||
*/ | ||
LeafletDirective.prototype.setMaxBounds = /** | ||
* Set the map's max bounds | ||
* @param latLngBounds the boundary to set | ||
*/ | ||
function (latLngBounds) { | ||
if (this.map && null != latLngBounds) { | ||
this.map.setMaxBounds(latLngBounds); | ||
} | ||
}; | ||
/** | ||
* Set the map's min zoom | ||
* @param number the new min zoom | ||
*/ | ||
/** | ||
LeafletDirective.prototype.setMaxBounds = function (latLngBounds) { | ||
if (this.map && null != latLngBounds) { | ||
this.map.setMaxBounds(latLngBounds); | ||
} | ||
}; | ||
/** | ||
* Set the map's min zoom | ||
* @param number the new min zoom | ||
*/ | ||
LeafletDirective.prototype.setMinZoom = /** | ||
LeafletDirective.prototype.setMinZoom = function (zoom) { | ||
if (this.map && null != zoom) { | ||
this.map.setMinZoom(zoom); | ||
} | ||
}; | ||
/** | ||
* Set the map's min zoom | ||
* @param number the new min zoom | ||
*/ | ||
function (zoom) { | ||
if (this.map && null != zoom) { | ||
this.map.setMinZoom(zoom); | ||
LeafletDirective.prototype.setMaxZoom = function (zoom) { | ||
if (this.map && null != zoom) { | ||
this.map.setMaxZoom(zoom); | ||
} | ||
}; | ||
LeafletDirective.decorators = [ | ||
{ type: core.Directive, args: [{ | ||
selector: '[leaflet]' | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
LeafletDirective.ctorParameters = function () { return [ | ||
{ type: core.ElementRef }, | ||
{ type: core.NgZone } | ||
]; }; | ||
LeafletDirective.propDecorators = { | ||
fitBoundsOptions: [{ type: core.Input, args: ['leafletFitBoundsOptions',] }], | ||
panOptions: [{ type: core.Input, args: ['leafletPanOptions',] }], | ||
zoomOptions: [{ type: core.Input, args: ['leafletZoomOptions',] }], | ||
zoomPanOptions: [{ type: core.Input, args: ['leafletZoomPanOptions',] }], | ||
options: [{ type: core.Input, args: ['leafletOptions',] }], | ||
mapReady: [{ type: core.Output, args: ['leafletMapReady',] }], | ||
zoom: [{ type: core.Input, args: ['leafletZoom',] }], | ||
zoomChange: [{ type: core.Output, args: ['leafletZoomChange',] }], | ||
center: [{ type: core.Input, args: ['leafletCenter',] }], | ||
centerChange: [{ type: core.Output, args: ['leafletCenterChange',] }], | ||
fitBounds: [{ type: core.Input, args: ['leafletFitBounds',] }], | ||
maxBounds: [{ type: core.Input, args: ['leafletMaxBounds',] }], | ||
minZoom: [{ type: core.Input, args: ['leafletMinZoom',] }], | ||
maxZoom: [{ type: core.Input, args: ['leafletMaxZoom',] }], | ||
onClick: [{ type: core.Output, args: ['leafletClick',] }], | ||
onDoubleClick: [{ type: core.Output, args: ['leafletDoubleClick',] }], | ||
onMouseDown: [{ type: core.Output, args: ['leafletMouseDown',] }], | ||
onMouseUp: [{ type: core.Output, args: ['leafletMouseUp',] }], | ||
onMouseMove: [{ type: core.Output, args: ['leafletMouseMove',] }], | ||
onMouseOver: [{ type: core.Output, args: ['leafletMouseOver',] }], | ||
onMapMove: [{ type: core.Output, args: ['leafletMapMove',] }], | ||
onMapMoveStart: [{ type: core.Output, args: ['leafletMapMoveStart',] }], | ||
onMapMoveEnd: [{ type: core.Output, args: ['leafletMapMoveEnd',] }], | ||
onMapZoom: [{ type: core.Output, args: ['leafletMapZoom',] }], | ||
onMapZoomStart: [{ type: core.Output, args: ['leafletMapZoomStart',] }], | ||
onMapZoomEnd: [{ type: core.Output, args: ['leafletMapZoomEnd',] }], | ||
onResize: [{ type: core.HostListener, args: ['window:resize', [],] }] | ||
}; | ||
return LeafletDirective; | ||
}()); | ||
var LeafletDirectiveWrapper = /** @class */ (function () { | ||
function LeafletDirectiveWrapper(leafletDirective) { | ||
this.leafletDirective = leafletDirective; | ||
} | ||
}; | ||
LeafletDirectiveWrapper.prototype.init = function () { | ||
// Nothing for now | ||
}; | ||
LeafletDirectiveWrapper.prototype.getMap = function () { | ||
return this.leafletDirective.getMap(); | ||
}; | ||
return LeafletDirectiveWrapper; | ||
}()); | ||
/** | ||
* Set the map's min zoom | ||
* @param number the new min zoom | ||
* Layer directive | ||
* | ||
* This directive is used to directly control a single map layer. The purpose of this directive is to | ||
* be used as part of a child structural directive of the map element. | ||
* | ||
*/ | ||
/** | ||
* Set the map's min zoom | ||
* @param number the new min zoom | ||
*/ | ||
LeafletDirective.prototype.setMaxZoom = /** | ||
* Set the map's min zoom | ||
* @param number the new min zoom | ||
*/ | ||
function (zoom) { | ||
if (this.map && null != zoom) { | ||
this.map.setMaxZoom(zoom); | ||
var LeafletLayerDirective = /** @class */ (function () { | ||
function LeafletLayerDirective(leafletDirective, zone) { | ||
this.zone = zone; | ||
// Layer Events | ||
this.onAdd = new core.EventEmitter(); | ||
this.onRemove = new core.EventEmitter(); | ||
this.leafletDirective = new LeafletDirectiveWrapper(leafletDirective); | ||
} | ||
}; | ||
LeafletDirective.decorators = [ | ||
{ type: core.Directive, args: [{ | ||
selector: '[leaflet]' | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
LeafletDirective.ctorParameters = function () { return [ | ||
{ type: core.ElementRef, }, | ||
{ type: core.NgZone, }, | ||
]; }; | ||
LeafletDirective.propDecorators = { | ||
"fitBoundsOptions": [{ type: core.Input, args: ['leafletFitBoundsOptions',] },], | ||
"panOptions": [{ type: core.Input, args: ['leafletPanOptions',] },], | ||
"zoomOptions": [{ type: core.Input, args: ['leafletZoomOptions',] },], | ||
"zoomPanOptions": [{ type: core.Input, args: ['leafletZoomPanOptions',] },], | ||
"options": [{ type: core.Input, args: ['leafletOptions',] },], | ||
"mapReady": [{ type: core.Output, args: ['leafletMapReady',] },], | ||
"zoom": [{ type: core.Input, args: ['leafletZoom',] },], | ||
"zoomChange": [{ type: core.Output, args: ['leafletZoomChange',] },], | ||
"center": [{ type: core.Input, args: ['leafletCenter',] },], | ||
"centerChange": [{ type: core.Output, args: ['leafletCenterChange',] },], | ||
"fitBounds": [{ type: core.Input, args: ['leafletFitBounds',] },], | ||
"maxBounds": [{ type: core.Input, args: ['leafletMaxBounds',] },], | ||
"minZoom": [{ type: core.Input, args: ['leafletMinZoom',] },], | ||
"maxZoom": [{ type: core.Input, args: ['leafletMaxZoom',] },], | ||
"onClick": [{ type: core.Output, args: ['leafletClick',] },], | ||
"onDoubleClick": [{ type: core.Output, args: ['leafletDoubleClick',] },], | ||
"onMouseDown": [{ type: core.Output, args: ['leafletMouseDown',] },], | ||
"onMouseUp": [{ type: core.Output, args: ['leafletMouseUp',] },], | ||
"onMouseMove": [{ type: core.Output, args: ['leafletMouseMove',] },], | ||
"onMouseOver": [{ type: core.Output, args: ['leafletMouseOver',] },], | ||
"onMapMove": [{ type: core.Output, args: ['leafletMapMove',] },], | ||
"onMapMoveStart": [{ type: core.Output, args: ['leafletMapMoveStart',] },], | ||
"onMapMoveEnd": [{ type: core.Output, args: ['leafletMapMoveEnd',] },], | ||
"onMapZoom": [{ type: core.Output, args: ['leafletMapZoom',] },], | ||
"onMapZoomStart": [{ type: core.Output, args: ['leafletMapZoomStart',] },], | ||
"onMapZoomEnd": [{ type: core.Output, args: ['leafletMapZoomEnd',] },], | ||
"onResize": [{ type: core.HostListener, args: ['window:resize', [],] },], | ||
}; | ||
return LeafletDirective; | ||
}()); | ||
LeafletLayerDirective.prototype.ngOnInit = function () { | ||
// Init the map | ||
this.leafletDirective.init(); | ||
}; | ||
LeafletLayerDirective.prototype.ngOnDestroy = function () { | ||
this.layer.remove(); | ||
}; | ||
LeafletLayerDirective.prototype.ngOnChanges = function (changes) { | ||
var _this = this; | ||
if (changes['layer']) { | ||
// Update the layer | ||
var p_1 = changes['layer'].previousValue; | ||
var n_1 = changes['layer'].currentValue; | ||
this.zone.runOutsideAngular(function () { | ||
if (null != p_1) { | ||
p_1.remove(); | ||
} | ||
if (null != n_1) { | ||
_this.addLayerEventListeners(n_1); | ||
_this.leafletDirective.getMap().addLayer(n_1); | ||
} | ||
}); | ||
} | ||
}; | ||
LeafletLayerDirective.prototype.addLayerEventListeners = function (l) { | ||
var _this = this; | ||
l.on('add', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onAdd, e); }); | ||
l.on('remove', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onRemove, e); }); | ||
}; | ||
LeafletLayerDirective.decorators = [ | ||
{ type: core.Directive, args: [{ | ||
selector: '[leafletLayer]' | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
LeafletLayerDirective.ctorParameters = function () { return [ | ||
{ type: LeafletDirective }, | ||
{ type: core.NgZone } | ||
]; }; | ||
LeafletLayerDirective.propDecorators = { | ||
layer: [{ type: core.Input, args: ['leafletLayer',] }], | ||
onAdd: [{ type: core.Output, args: ['leafletLayerAdd',] }], | ||
onRemove: [{ type: core.Output, args: ['leafletLayerRemove',] }] | ||
}; | ||
return LeafletLayerDirective; | ||
}()); | ||
var LeafletDirectiveWrapper = /** @class */ (function () { | ||
function LeafletDirectiveWrapper(leafletDirective) { | ||
this.leafletDirective = leafletDirective; | ||
} | ||
LeafletDirectiveWrapper.prototype.init = function () { | ||
// Nothing for now | ||
}; | ||
LeafletDirectiveWrapper.prototype.getMap = function () { | ||
return this.leafletDirective.getMap(); | ||
}; | ||
return LeafletDirectiveWrapper; | ||
}()); | ||
/** | ||
* Layer directive | ||
* | ||
* This directive is used to directly control a single map layer. The purpose of this directive is to | ||
* be used as part of a child structural directive of the map element. | ||
* | ||
*/ | ||
var LeafletLayerDirective = /** @class */ (function () { | ||
function LeafletLayerDirective(leafletDirective, zone) { | ||
this.zone = zone; | ||
// Layer Events | ||
this.onAdd = new core.EventEmitter(); | ||
this.onRemove = new core.EventEmitter(); | ||
this.leafletDirective = new LeafletDirectiveWrapper(leafletDirective); | ||
} | ||
LeafletLayerDirective.prototype.ngOnInit = function () { | ||
// Init the map | ||
this.leafletDirective.init(); | ||
}; | ||
LeafletLayerDirective.prototype.ngOnDestroy = function () { | ||
this.layer.remove(); | ||
}; | ||
LeafletLayerDirective.prototype.ngOnChanges = function (changes) { | ||
var _this = this; | ||
if (changes['layer']) { | ||
// Update the layer | ||
var p_1 = changes['layer'].previousValue; | ||
var n_1 = changes['layer'].currentValue; | ||
this.zone.runOutsideAngular(function () { | ||
if (null != p_1) { | ||
p_1.remove(); | ||
} | ||
if (null != n_1) { | ||
_this.addLayerEventListeners(n_1); | ||
_this.leafletDirective.getMap().addLayer(n_1); | ||
} | ||
}); | ||
/** | ||
* Layers directive | ||
* | ||
* This directive is used to directly control map layers. As changes are made to the input array of | ||
* layers, the map is synched to the array. As layers are added or removed from the input array, they | ||
* are also added or removed from the map. The input array is treated as immutable. To detect changes, | ||
* you must change the array instance. | ||
* | ||
* Important Note: The input layers array is assumed to be immutable. This means you need to use an | ||
* immutable array implementation or create a new copy of your array when you make changes, otherwise | ||
* this directive won't detect the change. This is by design. It's for performance reasons. Change | ||
* detection of mutable arrays requires diffing the state of the array on every DoCheck cycle, which | ||
* is extremely expensive from a time complexity perspective. | ||
* | ||
*/ | ||
var LeafletLayersDirective = /** @class */ (function () { | ||
function LeafletLayersDirective(leafletDirective, differs, zone) { | ||
this.differs = differs; | ||
this.zone = zone; | ||
this.leafletDirective = new LeafletDirectiveWrapper(leafletDirective); | ||
this.layersDiffer = this.differs.find([]).create(); | ||
} | ||
}; | ||
LeafletLayerDirective.prototype.addLayerEventListeners = function (l) { | ||
var _this = this; | ||
l.on('add', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onAdd, e); }); | ||
l.on('remove', function (e) { return LeafletUtil.handleEvent(_this.zone, _this.onRemove, e); }); | ||
}; | ||
LeafletLayerDirective.decorators = [ | ||
{ type: core.Directive, args: [{ | ||
selector: '[leafletLayer]' | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
LeafletLayerDirective.ctorParameters = function () { return [ | ||
{ type: LeafletDirective, }, | ||
{ type: core.NgZone, }, | ||
]; }; | ||
LeafletLayerDirective.propDecorators = { | ||
"layer": [{ type: core.Input, args: ['leafletLayer',] },], | ||
"onAdd": [{ type: core.Output, args: ['leafletLayerAdd',] },], | ||
"onRemove": [{ type: core.Output, args: ['leafletLayerRemove',] },], | ||
}; | ||
return LeafletLayerDirective; | ||
}()); | ||
/** | ||
* Layers directive | ||
* | ||
* This directive is used to directly control map layers. As changes are made to the input array of | ||
* layers, the map is synched to the array. As layers are added or removed from the input array, they | ||
* are also added or removed from the map. The input array is treated as immutable. To detect changes, | ||
* you must change the array instance. | ||
* | ||
* Important Note: The input layers array is assumed to be immutable. This means you need to use an | ||
* immutable array implementation or create a new copy of your array when you make changes, otherwise | ||
* this directive won't detect the change. This is by design. It's for performance reasons. Change | ||
* detection of mutable arrays requires diffing the state of the array on every DoCheck cycle, which | ||
* is extremely expensive from a time complexity perspective. | ||
* | ||
*/ | ||
var LeafletLayersDirective = /** @class */ (function () { | ||
function LeafletLayersDirective(leafletDirective, differs, zone) { | ||
this.differs = differs; | ||
this.zone = zone; | ||
this.leafletDirective = new LeafletDirectiveWrapper(leafletDirective); | ||
this.layersDiffer = this.differs.find([]).create(); | ||
} | ||
Object.defineProperty(LeafletLayersDirective.prototype, "layers", { | ||
get: function () { | ||
return this.layersValue; | ||
}, | ||
set: | ||
// Set/get the layers | ||
function (v) { | ||
this.layersValue = v; | ||
// Now that we have a differ, do an immediate layer update | ||
Object.defineProperty(LeafletLayersDirective.prototype, "layers", { | ||
get: function () { | ||
return this.layersValue; | ||
}, | ||
// Set/get the layers | ||
set: function (v) { | ||
this.layersValue = v; | ||
// Now that we have a differ, do an immediate layer update | ||
this.updateLayers(); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
LeafletLayersDirective.prototype.ngDoCheck = function () { | ||
this.updateLayers(); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
LeafletLayersDirective.prototype.ngDoCheck = function () { | ||
this.updateLayers(); | ||
}; | ||
LeafletLayersDirective.prototype.ngOnInit = function () { | ||
// Init the map | ||
this.leafletDirective.init(); | ||
// Update layers once the map is ready | ||
this.updateLayers(); | ||
}; | ||
LeafletLayersDirective.prototype.ngOnDestroy = function () { | ||
this.layers = []; | ||
}; | ||
/** | ||
* Update the state of the layers. | ||
* We use an iterable differ to synchronize the map layers with the state of the bound layers array. | ||
* This is important because it allows us to react to changes to the contents of the array as well | ||
* as changes to the actual array instance. | ||
*/ | ||
/** | ||
}; | ||
LeafletLayersDirective.prototype.ngOnInit = function () { | ||
// Init the map | ||
this.leafletDirective.init(); | ||
// Update layers once the map is ready | ||
this.updateLayers(); | ||
}; | ||
LeafletLayersDirective.prototype.ngOnDestroy = function () { | ||
this.layers = []; | ||
}; | ||
/** | ||
* Update the state of the layers. | ||
@@ -499,381 +420,359 @@ * We use an iterable differ to synchronize the map layers with the state of the bound layers array. | ||
*/ | ||
LeafletLayersDirective.prototype.updateLayers = /** | ||
* Update the state of the layers. | ||
* We use an iterable differ to synchronize the map layers with the state of the bound layers array. | ||
* This is important because it allows us to react to changes to the contents of the array as well | ||
* as changes to the actual array instance. | ||
*/ | ||
function () { | ||
var map$$1 = this.leafletDirective.getMap(); | ||
if (null != map$$1 && null != this.layersDiffer) { | ||
var changes_1 = this.layersDiffer.diff(this.layersValue); | ||
if (null != changes_1) { | ||
// Run outside angular to ensure layer events don't trigger change detection | ||
this.zone.runOutsideAngular(function () { | ||
changes_1.forEachRemovedItem(function (c) { | ||
map$$1.removeLayer(c.item); | ||
LeafletLayersDirective.prototype.updateLayers = function () { | ||
var map = this.leafletDirective.getMap(); | ||
if (null != map && null != this.layersDiffer) { | ||
var changes_1 = this.layersDiffer.diff(this.layersValue); | ||
if (null != changes_1) { | ||
// Run outside angular to ensure layer events don't trigger change detection | ||
this.zone.runOutsideAngular(function () { | ||
changes_1.forEachRemovedItem(function (c) { | ||
map.removeLayer(c.item); | ||
}); | ||
changes_1.forEachAddedItem(function (c) { | ||
map.addLayer(c.item); | ||
}); | ||
}); | ||
changes_1.forEachAddedItem(function (c) { | ||
map$$1.addLayer(c.item); | ||
}); | ||
}); | ||
} | ||
} | ||
}; | ||
LeafletLayersDirective.decorators = [ | ||
{ type: core.Directive, args: [{ | ||
selector: '[leafletLayers]' | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
LeafletLayersDirective.ctorParameters = function () { return [ | ||
{ type: LeafletDirective }, | ||
{ type: core.IterableDiffers }, | ||
{ type: core.NgZone } | ||
]; }; | ||
LeafletLayersDirective.propDecorators = { | ||
layers: [{ type: core.Input, args: ['leafletLayers',] }] | ||
}; | ||
return LeafletLayersDirective; | ||
}()); | ||
var LeafletControlLayersChanges = /** @class */ (function () { | ||
function LeafletControlLayersChanges() { | ||
this.layersRemoved = 0; | ||
this.layersChanged = 0; | ||
this.layersAdded = 0; | ||
} | ||
}; | ||
LeafletLayersDirective.decorators = [ | ||
{ type: core.Directive, args: [{ | ||
selector: '[leafletLayers]' | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
LeafletLayersDirective.ctorParameters = function () { return [ | ||
{ type: LeafletDirective, }, | ||
{ type: core.IterableDiffers, }, | ||
{ type: core.NgZone, }, | ||
]; }; | ||
LeafletLayersDirective.propDecorators = { | ||
"layers": [{ type: core.Input, args: ['leafletLayers',] },], | ||
}; | ||
return LeafletLayersDirective; | ||
}()); | ||
LeafletControlLayersChanges.prototype.changed = function () { | ||
return !(this.layersRemoved === 0 && this.layersChanged === 0 && this.layersAdded === 0); | ||
}; | ||
return LeafletControlLayersChanges; | ||
}()); | ||
var LeafletControlLayersChanges = /** @class */ (function () { | ||
function LeafletControlLayersChanges() { | ||
this.layersRemoved = 0; | ||
this.layersChanged = 0; | ||
this.layersAdded = 0; | ||
} | ||
LeafletControlLayersChanges.prototype.changed = function () { | ||
return !(this.layersRemoved === 0 && this.layersChanged === 0 && this.layersAdded === 0); | ||
}; | ||
return LeafletControlLayersChanges; | ||
}()); | ||
var LeafletControlLayersWrapper = /** @class */ (function () { | ||
function LeafletControlLayersWrapper(zone, layersControlReady) { | ||
this.zone = zone; | ||
this.layersControlReady = layersControlReady; | ||
} | ||
LeafletControlLayersWrapper.prototype.getLayersControl = function () { | ||
return this.layersControl; | ||
}; | ||
LeafletControlLayersWrapper.prototype.init = function (controlConfig, controlOptions) { | ||
var _this = this; | ||
var baseLayers = controlConfig.baseLayers || {}; | ||
var overlays = controlConfig.overlays || {}; | ||
// Create the control outside of angular to ensure events don't trigger change detection | ||
this.zone.runOutsideAngular(function () { | ||
_this.layersControl = leaflet.control.layers(baseLayers, overlays, controlOptions); | ||
}); | ||
this.layersControlReady.emit(this.layersControl); | ||
return this.layersControl; | ||
}; | ||
LeafletControlLayersWrapper.prototype.applyBaseLayerChanges = function (changes) { | ||
var results = new LeafletControlLayersChanges(); | ||
if (null != this.layersControl) { | ||
results = this.applyChanges(changes, this.layersControl.addBaseLayer); | ||
var LeafletControlLayersWrapper = /** @class */ (function () { | ||
function LeafletControlLayersWrapper(zone, layersControlReady) { | ||
this.zone = zone; | ||
this.layersControlReady = layersControlReady; | ||
} | ||
return results; | ||
}; | ||
LeafletControlLayersWrapper.prototype.applyOverlayChanges = function (changes) { | ||
var results = new LeafletControlLayersChanges(); | ||
if (null != this.layersControl) { | ||
results = this.applyChanges(changes, this.layersControl.addOverlay); | ||
} | ||
return results; | ||
}; | ||
LeafletControlLayersWrapper.prototype.applyChanges = function (changes, addFn) { | ||
var _this = this; | ||
var results = new LeafletControlLayersChanges(); | ||
if (null != changes) { | ||
// All layer management is outside angular to avoid layer events from triggering change detection | ||
LeafletControlLayersWrapper.prototype.getLayersControl = function () { | ||
return this.layersControl; | ||
}; | ||
LeafletControlLayersWrapper.prototype.init = function (controlConfig, controlOptions) { | ||
var _this = this; | ||
var baseLayers = controlConfig.baseLayers || {}; | ||
var overlays = controlConfig.overlays || {}; | ||
// Create the control outside of angular to ensure events don't trigger change detection | ||
this.zone.runOutsideAngular(function () { | ||
changes.forEachChangedItem(function (c) { | ||
_this.layersControl.removeLayer(c.previousValue); | ||
addFn.call(_this.layersControl, c.currentValue, c.key); | ||
results.layersChanged++; | ||
}); | ||
changes.forEachRemovedItem(function (c) { | ||
_this.layersControl.removeLayer(c.previousValue); | ||
results.layersRemoved++; | ||
}); | ||
changes.forEachAddedItem(function (c) { | ||
addFn.call(_this.layersControl, c.currentValue, c.key); | ||
results.layersAdded++; | ||
}); | ||
_this.layersControl = leaflet.control.layers(baseLayers, overlays, controlOptions); | ||
}); | ||
} | ||
return results; | ||
}; | ||
return LeafletControlLayersWrapper; | ||
}()); | ||
var LeafletControlLayersConfig = /** @class */ (function () { | ||
function LeafletControlLayersConfig() { | ||
this.baseLayers = {}; | ||
this.overlays = {}; | ||
} | ||
return LeafletControlLayersConfig; | ||
}()); | ||
/** | ||
* Layers Control | ||
* | ||
* This directive is used to configure the layers control. The input accepts an object with two | ||
* key-value maps of layer name -> layer. Mutable changes are detected. On changes, a differ is | ||
* used to determine what changed so that layers are appropriately added or removed. | ||
* | ||
* To specify which layer to show as the 'active' baselayer, you will want to add it to the map | ||
* using the layers directive. Otherwise, the last one it sees will be used. | ||
*/ | ||
var LeafletLayersControlDirective = /** @class */ (function () { | ||
function LeafletLayersControlDirective(leafletDirective, differs, zone) { | ||
this.differs = differs; | ||
this.zone = zone; | ||
this.layersControlReady = new core.EventEmitter(); | ||
this.leafletDirective = new LeafletDirectiveWrapper(leafletDirective); | ||
this.controlLayers = new LeafletControlLayersWrapper(this.zone, this.layersControlReady); | ||
// Generate differs | ||
this.baseLayersDiffer = this.differs.find({}).create(); | ||
this.overlaysDiffer = this.differs.find({}).create(); | ||
} | ||
Object.defineProperty(LeafletLayersControlDirective.prototype, "layersControlConfig", { | ||
get: function () { | ||
return this.layersControlConfigValue; | ||
}, | ||
set: function (v) { | ||
// Validation/init stuff | ||
if (null == v) { | ||
v = new LeafletControlLayersConfig(); | ||
this.layersControlReady.emit(this.layersControl); | ||
return this.layersControl; | ||
}; | ||
LeafletControlLayersWrapper.prototype.applyBaseLayerChanges = function (changes) { | ||
var results = new LeafletControlLayersChanges(); | ||
if (null != this.layersControl) { | ||
results = this.applyChanges(changes, this.layersControl.addBaseLayer); | ||
} | ||
if (null == v.baseLayers) { | ||
v.baseLayers = {}; | ||
return results; | ||
}; | ||
LeafletControlLayersWrapper.prototype.applyOverlayChanges = function (changes) { | ||
var results = new LeafletControlLayersChanges(); | ||
if (null != this.layersControl) { | ||
results = this.applyChanges(changes, this.layersControl.addOverlay); | ||
} | ||
if (null == v.overlays) { | ||
v.overlays = {}; | ||
return results; | ||
}; | ||
LeafletControlLayersWrapper.prototype.applyChanges = function (changes, addFn) { | ||
var _this = this; | ||
var results = new LeafletControlLayersChanges(); | ||
if (null != changes) { | ||
// All layer management is outside angular to avoid layer events from triggering change detection | ||
this.zone.runOutsideAngular(function () { | ||
changes.forEachChangedItem(function (c) { | ||
_this.layersControl.removeLayer(c.previousValue); | ||
addFn.call(_this.layersControl, c.currentValue, c.key); | ||
results.layersChanged++; | ||
}); | ||
changes.forEachRemovedItem(function (c) { | ||
_this.layersControl.removeLayer(c.previousValue); | ||
results.layersRemoved++; | ||
}); | ||
changes.forEachAddedItem(function (c) { | ||
addFn.call(_this.layersControl, c.currentValue, c.key); | ||
results.layersAdded++; | ||
}); | ||
}); | ||
} | ||
// Store the value | ||
this.layersControlConfigValue = v; | ||
// Update the map | ||
this.updateLayers(); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
LeafletLayersControlDirective.prototype.ngOnInit = function () { | ||
var _this = this; | ||
// Init the map | ||
this.leafletDirective.init(); | ||
// Set up control outside of angular to avoid change detection when using the control | ||
this.zone.runOutsideAngular(function () { | ||
// Set up all the initial settings | ||
// Set up all the initial settings | ||
_this.controlLayers | ||
.init({}, _this.layersControlOptions) | ||
.addTo(_this.leafletDirective.getMap()); | ||
}); | ||
this.updateLayers(); | ||
}; | ||
LeafletLayersControlDirective.prototype.ngOnDestroy = function () { | ||
this.layersControlConfig = { baseLayers: {}, overlays: {} }; | ||
this.controlLayers.getLayersControl().remove(); | ||
}; | ||
LeafletLayersControlDirective.prototype.ngDoCheck = function () { | ||
this.updateLayers(); | ||
}; | ||
LeafletLayersControlDirective.prototype.updateLayers = function () { | ||
var map$$1 = this.leafletDirective.getMap(); | ||
var layersControl = this.controlLayers.getLayersControl(); | ||
if (null != map$$1 && null != layersControl) { | ||
// Run the baselayers differ | ||
if (null != this.baseLayersDiffer && null != this.layersControlConfigValue.baseLayers) { | ||
var changes = this.baseLayersDiffer.diff(this.layersControlConfigValue.baseLayers); | ||
this.controlLayers.applyBaseLayerChanges(changes); | ||
} | ||
// Run the overlays differ | ||
if (null != this.overlaysDiffer && null != this.layersControlConfigValue.overlays) { | ||
var changes = this.overlaysDiffer.diff(this.layersControlConfigValue.overlays); | ||
this.controlLayers.applyOverlayChanges(changes); | ||
} | ||
return results; | ||
}; | ||
return LeafletControlLayersWrapper; | ||
}()); | ||
var LeafletControlLayersConfig = /** @class */ (function () { | ||
function LeafletControlLayersConfig() { | ||
this.baseLayers = {}; | ||
this.overlays = {}; | ||
} | ||
}; | ||
LeafletLayersControlDirective.decorators = [ | ||
{ type: core.Directive, args: [{ | ||
selector: '[leafletLayersControl]' | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
LeafletLayersControlDirective.ctorParameters = function () { return [ | ||
{ type: LeafletDirective, }, | ||
{ type: core.KeyValueDiffers, }, | ||
{ type: core.NgZone, }, | ||
]; }; | ||
LeafletLayersControlDirective.propDecorators = { | ||
"layersControlConfig": [{ type: core.Input, args: ['leafletLayersControl',] },], | ||
"layersControlOptions": [{ type: core.Input, args: ['leafletLayersControlOptions',] },], | ||
"layersControlReady": [{ type: core.Output, args: ['leafletLayersControlReady',] },], | ||
}; | ||
return LeafletLayersControlDirective; | ||
}()); | ||
return LeafletControlLayersConfig; | ||
}()); | ||
/** | ||
* Baselayers directive | ||
* | ||
* This directive is provided as a convenient way to add baselayers to the map. The input accepts | ||
* a key-value map of layer name -> layer. Mutable changed are detected. On changes, a differ is | ||
* used to determine what changed so that layers are appropriately added or removed. This directive | ||
* will also add the layers control so users can switch between available base layers. | ||
* | ||
* To specify which layer to show as the 'active' baselayer, you will want to add it to the map | ||
* using the layers directive. Otherwise, the plugin will use the last one it sees. | ||
*/ | ||
var LeafletBaseLayersDirective = /** @class */ (function () { | ||
function LeafletBaseLayersDirective(leafletDirective, differs, zone) { | ||
this.differs = differs; | ||
this.zone = zone; | ||
// Output for once the layers control is ready | ||
this.layersControlReady = new core.EventEmitter(); | ||
this.leafletDirective = new LeafletDirectiveWrapper(leafletDirective); | ||
this.controlLayers = new LeafletControlLayersWrapper(this.zone, this.layersControlReady); | ||
this.baseLayersDiffer = this.differs.find({}).create(); | ||
} | ||
Object.defineProperty(LeafletBaseLayersDirective.prototype, "baseLayers", { | ||
get: function () { | ||
return this.baseLayersValue; | ||
}, | ||
set: | ||
// Set/get baseLayers | ||
function (v) { | ||
this.baseLayersValue = v; | ||
this.updateBaseLayers(); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
LeafletBaseLayersDirective.prototype.ngOnDestroy = function () { | ||
this.baseLayers = {}; | ||
this.controlLayers.getLayersControl().remove(); | ||
}; | ||
LeafletBaseLayersDirective.prototype.ngOnInit = function () { | ||
var _this = this; | ||
// Init the map | ||
this.leafletDirective.init(); | ||
// Create the control outside angular to prevent events from triggering chnage detection | ||
this.zone.runOutsideAngular(function () { | ||
// Initially configure the controlLayers | ||
// Initially configure the controlLayers | ||
_this.controlLayers | ||
.init({}, _this.layersControlOptions) | ||
.addTo(_this.leafletDirective.getMap()); | ||
/** | ||
* Layers Control | ||
* | ||
* This directive is used to configure the layers control. The input accepts an object with two | ||
* key-value maps of layer name -> layer. Mutable changes are detected. On changes, a differ is | ||
* used to determine what changed so that layers are appropriately added or removed. | ||
* | ||
* To specify which layer to show as the 'active' baselayer, you will want to add it to the map | ||
* using the layers directive. Otherwise, the last one it sees will be used. | ||
*/ | ||
var LeafletLayersControlDirective = /** @class */ (function () { | ||
function LeafletLayersControlDirective(leafletDirective, differs, zone) { | ||
this.differs = differs; | ||
this.zone = zone; | ||
this.layersControlReady = new core.EventEmitter(); | ||
this.leafletDirective = new LeafletDirectiveWrapper(leafletDirective); | ||
this.controlLayers = new LeafletControlLayersWrapper(this.zone, this.layersControlReady); | ||
// Generate differs | ||
this.baseLayersDiffer = this.differs.find({}).create(); | ||
this.overlaysDiffer = this.differs.find({}).create(); | ||
} | ||
Object.defineProperty(LeafletLayersControlDirective.prototype, "layersControlConfig", { | ||
get: function () { | ||
return this.layersControlConfigValue; | ||
}, | ||
set: function (v) { | ||
// Validation/init stuff | ||
if (null == v) { | ||
v = new LeafletControlLayersConfig(); | ||
} | ||
if (null == v.baseLayers) { | ||
v.baseLayers = {}; | ||
} | ||
if (null == v.overlays) { | ||
v.overlays = {}; | ||
} | ||
// Store the value | ||
this.layersControlConfigValue = v; | ||
// Update the map | ||
this.updateLayers(); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
this.updateBaseLayers(); | ||
}; | ||
LeafletBaseLayersDirective.prototype.ngDoCheck = function () { | ||
this.updateBaseLayers(); | ||
}; | ||
LeafletBaseLayersDirective.prototype.updateBaseLayers = function () { | ||
var map$$1 = this.leafletDirective.getMap(); | ||
var layersControl = this.controlLayers.getLayersControl(); | ||
if (null != map$$1 && null != layersControl && null != this.baseLayersDiffer) { | ||
var changes = this.baseLayersDiffer.diff(this.baseLayersValue); | ||
var results = this.controlLayers.applyBaseLayerChanges(changes); | ||
if (results.changed()) { | ||
this.syncBaseLayer(); | ||
LeafletLayersControlDirective.prototype.ngOnInit = function () { | ||
var _this = this; | ||
// Init the map | ||
this.leafletDirective.init(); | ||
// Set up control outside of angular to avoid change detection when using the control | ||
this.zone.runOutsideAngular(function () { | ||
// Set up all the initial settings | ||
_this.controlLayers | ||
.init({}, _this.layersControlOptions) | ||
.addTo(_this.leafletDirective.getMap()); | ||
}); | ||
this.updateLayers(); | ||
}; | ||
LeafletLayersControlDirective.prototype.ngOnDestroy = function () { | ||
this.layersControlConfig = { baseLayers: {}, overlays: {} }; | ||
this.controlLayers.getLayersControl().remove(); | ||
}; | ||
LeafletLayersControlDirective.prototype.ngDoCheck = function () { | ||
this.updateLayers(); | ||
}; | ||
LeafletLayersControlDirective.prototype.updateLayers = function () { | ||
var map = this.leafletDirective.getMap(); | ||
var layersControl = this.controlLayers.getLayersControl(); | ||
if (null != map && null != layersControl) { | ||
// Run the baselayers differ | ||
if (null != this.baseLayersDiffer && null != this.layersControlConfigValue.baseLayers) { | ||
var changes = this.baseLayersDiffer.diff(this.layersControlConfigValue.baseLayers); | ||
this.controlLayers.applyBaseLayerChanges(changes); | ||
} | ||
// Run the overlays differ | ||
if (null != this.overlaysDiffer && null != this.layersControlConfigValue.overlays) { | ||
var changes = this.overlaysDiffer.diff(this.layersControlConfigValue.overlays); | ||
this.controlLayers.applyOverlayChanges(changes); | ||
} | ||
} | ||
} | ||
}; | ||
}; | ||
LeafletLayersControlDirective.decorators = [ | ||
{ type: core.Directive, args: [{ | ||
selector: '[leafletLayersControl]' | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
LeafletLayersControlDirective.ctorParameters = function () { return [ | ||
{ type: LeafletDirective }, | ||
{ type: core.KeyValueDiffers }, | ||
{ type: core.NgZone } | ||
]; }; | ||
LeafletLayersControlDirective.propDecorators = { | ||
layersControlConfig: [{ type: core.Input, args: ['leafletLayersControl',] }], | ||
layersControlOptions: [{ type: core.Input, args: ['leafletLayersControlOptions',] }], | ||
layersControlReady: [{ type: core.Output, args: ['leafletLayersControlReady',] }] | ||
}; | ||
return LeafletLayersControlDirective; | ||
}()); | ||
/** | ||
* Check the current base layer and change it to the new one if necessary | ||
* Baselayers directive | ||
* | ||
* This directive is provided as a convenient way to add baselayers to the map. The input accepts | ||
* a key-value map of layer name -> layer. Mutable changed are detected. On changes, a differ is | ||
* used to determine what changed so that layers are appropriately added or removed. This directive | ||
* will also add the layers control so users can switch between available base layers. | ||
* | ||
* To specify which layer to show as the 'active' baselayer, you will want to add it to the map | ||
* using the layers directive. Otherwise, the plugin will use the last one it sees. | ||
*/ | ||
/** | ||
var LeafletBaseLayersDirective = /** @class */ (function () { | ||
function LeafletBaseLayersDirective(leafletDirective, differs, zone) { | ||
this.differs = differs; | ||
this.zone = zone; | ||
// Output for once the layers control is ready | ||
this.layersControlReady = new core.EventEmitter(); | ||
this.leafletDirective = new LeafletDirectiveWrapper(leafletDirective); | ||
this.controlLayers = new LeafletControlLayersWrapper(this.zone, this.layersControlReady); | ||
this.baseLayersDiffer = this.differs.find({}).create(); | ||
} | ||
Object.defineProperty(LeafletBaseLayersDirective.prototype, "baseLayers", { | ||
get: function () { | ||
return this.baseLayersValue; | ||
}, | ||
// Set/get baseLayers | ||
set: function (v) { | ||
this.baseLayersValue = v; | ||
this.updateBaseLayers(); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
LeafletBaseLayersDirective.prototype.ngOnDestroy = function () { | ||
this.baseLayers = {}; | ||
this.controlLayers.getLayersControl().remove(); | ||
}; | ||
LeafletBaseLayersDirective.prototype.ngOnInit = function () { | ||
var _this = this; | ||
// Init the map | ||
this.leafletDirective.init(); | ||
// Create the control outside angular to prevent events from triggering chnage detection | ||
this.zone.runOutsideAngular(function () { | ||
// Initially configure the controlLayers | ||
_this.controlLayers | ||
.init({}, _this.layersControlOptions) | ||
.addTo(_this.leafletDirective.getMap()); | ||
}); | ||
this.updateBaseLayers(); | ||
}; | ||
LeafletBaseLayersDirective.prototype.ngDoCheck = function () { | ||
this.updateBaseLayers(); | ||
}; | ||
LeafletBaseLayersDirective.prototype.updateBaseLayers = function () { | ||
var map = this.leafletDirective.getMap(); | ||
var layersControl = this.controlLayers.getLayersControl(); | ||
if (null != map && null != layersControl && null != this.baseLayersDiffer) { | ||
var changes = this.baseLayersDiffer.diff(this.baseLayersValue); | ||
var results = this.controlLayers.applyBaseLayerChanges(changes); | ||
if (results.changed()) { | ||
this.syncBaseLayer(); | ||
} | ||
} | ||
}; | ||
/** | ||
* Check the current base layer and change it to the new one if necessary | ||
*/ | ||
LeafletBaseLayersDirective.prototype.syncBaseLayer = /** | ||
* Check the current base layer and change it to the new one if necessary | ||
*/ | ||
function () { | ||
var _this = this; | ||
var map$$1 = this.leafletDirective.getMap(); | ||
var layers = LeafletUtil.mapToArray(this.baseLayers); | ||
var foundLayer; | ||
// Search all the layers in the map to see if we can find them in the baselayer array | ||
map$$1.eachLayer(function (l) { | ||
foundLayer = layers.find(function (bl) { return (l === bl); }); | ||
}); | ||
// Did we find the layer? | ||
if (null != foundLayer) { | ||
// Yes - set the baselayer to the one we found | ||
this.baseLayer = foundLayer; | ||
} | ||
else { | ||
// No - set the baselayer to the first in the array and add it to the map | ||
if (layers.length > 0) { | ||
this.baseLayer = layers[0]; | ||
// Add layers outside of angular to prevent events from triggering change detection | ||
this.zone.runOutsideAngular(function () { | ||
_this.baseLayer.addTo(map$$1); | ||
}); | ||
LeafletBaseLayersDirective.prototype.syncBaseLayer = function () { | ||
var _this = this; | ||
var map = this.leafletDirective.getMap(); | ||
var layers = LeafletUtil.mapToArray(this.baseLayers); | ||
var foundLayer; | ||
// Search all the layers in the map to see if we can find them in the baselayer array | ||
map.eachLayer(function (l) { | ||
foundLayer = layers.find(function (bl) { return (l === bl); }); | ||
}); | ||
// Did we find the layer? | ||
if (null != foundLayer) { | ||
// Yes - set the baselayer to the one we found | ||
this.baseLayer = foundLayer; | ||
} | ||
else { | ||
// No - set the baselayer to the first in the array and add it to the map | ||
if (layers.length > 0) { | ||
this.baseLayer = layers[0]; | ||
// Add layers outside of angular to prevent events from triggering change detection | ||
this.zone.runOutsideAngular(function () { | ||
_this.baseLayer.addTo(map); | ||
}); | ||
} | ||
} | ||
}; | ||
LeafletBaseLayersDirective.decorators = [ | ||
{ type: core.Directive, args: [{ | ||
selector: '[leafletBaseLayers]' | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
LeafletBaseLayersDirective.ctorParameters = function () { return [ | ||
{ type: LeafletDirective }, | ||
{ type: core.KeyValueDiffers }, | ||
{ type: core.NgZone } | ||
]; }; | ||
LeafletBaseLayersDirective.propDecorators = { | ||
baseLayers: [{ type: core.Input, args: ['leafletBaseLayers',] }], | ||
layersControlOptions: [{ type: core.Input, args: ['leafletLayersControlOptions',] }], | ||
layersControlReady: [{ type: core.Output, args: ['leafletLayersControlReady',] }] | ||
}; | ||
return LeafletBaseLayersDirective; | ||
}()); | ||
var LeafletModule = /** @class */ (function () { | ||
function LeafletModule() { | ||
} | ||
}; | ||
LeafletBaseLayersDirective.decorators = [ | ||
{ type: core.Directive, args: [{ | ||
selector: '[leafletBaseLayers]' | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
LeafletBaseLayersDirective.ctorParameters = function () { return [ | ||
{ type: LeafletDirective, }, | ||
{ type: core.KeyValueDiffers, }, | ||
{ type: core.NgZone, }, | ||
]; }; | ||
LeafletBaseLayersDirective.propDecorators = { | ||
"baseLayers": [{ type: core.Input, args: ['leafletBaseLayers',] },], | ||
"layersControlOptions": [{ type: core.Input, args: ['leafletLayersControlOptions',] },], | ||
"layersControlReady": [{ type: core.Output, args: ['leafletLayersControlReady',] },], | ||
}; | ||
return LeafletBaseLayersDirective; | ||
}()); | ||
LeafletModule.forRoot = function () { | ||
return { ngModule: LeafletModule, providers: [] }; | ||
}; | ||
LeafletModule.decorators = [ | ||
{ type: core.NgModule, args: [{ | ||
exports: [ | ||
LeafletDirective, | ||
LeafletLayerDirective, | ||
LeafletLayersDirective, | ||
LeafletLayersControlDirective, | ||
LeafletBaseLayersDirective | ||
], | ||
declarations: [ | ||
LeafletDirective, | ||
LeafletLayerDirective, | ||
LeafletLayersDirective, | ||
LeafletLayersControlDirective, | ||
LeafletBaseLayersDirective | ||
] | ||
},] }, | ||
]; | ||
return LeafletModule; | ||
}()); | ||
var LeafletModule = /** @class */ (function () { | ||
function LeafletModule() { | ||
} | ||
LeafletModule.forRoot = function () { | ||
return { ngModule: LeafletModule, providers: [] }; | ||
}; | ||
LeafletModule.decorators = [ | ||
{ type: core.NgModule, args: [{ | ||
exports: [ | ||
LeafletDirective, | ||
LeafletLayerDirective, | ||
LeafletLayersDirective, | ||
LeafletLayersControlDirective, | ||
LeafletBaseLayersDirective | ||
], | ||
declarations: [ | ||
LeafletDirective, | ||
LeafletLayerDirective, | ||
LeafletLayersDirective, | ||
LeafletLayersControlDirective, | ||
LeafletBaseLayersDirective | ||
] | ||
},] }, | ||
]; | ||
return LeafletModule; | ||
}()); | ||
var LeafletTileLayerDefinition = /** @class */ (function () { | ||
function LeafletTileLayerDefinition(type, url, options) { | ||
this.type = type; | ||
this.url = url; | ||
this.options = options; | ||
} | ||
/** | ||
* Creates a TileLayer from the provided definition. This is a convenience function | ||
* to help with generating layers from objects. | ||
* | ||
* @param layerDef The layer to create | ||
* @returns {TileLayer} The TileLayer that has been created | ||
*/ | ||
/** | ||
var LeafletTileLayerDefinition = /** @class */ (function () { | ||
function LeafletTileLayerDefinition(type, url, options) { | ||
this.type = type; | ||
this.url = url; | ||
this.options = options; | ||
} | ||
/** | ||
* Creates a TileLayer from the provided definition. This is a convenience function | ||
@@ -885,30 +784,16 @@ * to help with generating layers from objects. | ||
*/ | ||
LeafletTileLayerDefinition.createTileLayer = /** | ||
* Creates a TileLayer from the provided definition. This is a convenience function | ||
* to help with generating layers from objects. | ||
* | ||
* @param layerDef The layer to create | ||
* @returns {TileLayer} The TileLayer that has been created | ||
*/ | ||
function (layerDef) { | ||
var layer; | ||
switch (layerDef.type) { | ||
case 'xyz': | ||
layer = leaflet.tileLayer(layerDef.url, layerDef.options); | ||
break; | ||
case 'wms': | ||
default: | ||
layer = leaflet.tileLayer.wms(layerDef.url, layerDef.options); | ||
break; | ||
} | ||
return layer; | ||
}; | ||
/** | ||
* Creates a TileLayer for each key in the incoming map. This is a convenience function | ||
* for generating an associative array of layers from an associative array of objects | ||
* | ||
* @param layerDefs A map of key to tile layer definition | ||
* @returns {{[p: string]: TileLayer}} A new map of key to TileLayer | ||
*/ | ||
/** | ||
LeafletTileLayerDefinition.createTileLayer = function (layerDef) { | ||
var layer; | ||
switch (layerDef.type) { | ||
case 'xyz': | ||
layer = leaflet.tileLayer(layerDef.url, layerDef.options); | ||
break; | ||
case 'wms': | ||
default: | ||
layer = leaflet.tileLayer.wms(layerDef.url, layerDef.options); | ||
break; | ||
} | ||
return layer; | ||
}; | ||
/** | ||
* Creates a TileLayer for each key in the incoming map. This is a convenience function | ||
@@ -920,24 +805,12 @@ * for generating an associative array of layers from an associative array of objects | ||
*/ | ||
LeafletTileLayerDefinition.createTileLayers = /** | ||
* Creates a TileLayer for each key in the incoming map. This is a convenience function | ||
* for generating an associative array of layers from an associative array of objects | ||
* | ||
* @param layerDefs A map of key to tile layer definition | ||
* @returns {{[p: string]: TileLayer}} A new map of key to TileLayer | ||
*/ | ||
function (layerDefs) { | ||
var layers = {}; | ||
for (var k in layerDefs) { | ||
if (layerDefs.hasOwnProperty(k)) { | ||
layers[k] = (LeafletTileLayerDefinition.createTileLayer(layerDefs[k])); | ||
LeafletTileLayerDefinition.createTileLayers = function (layerDefs) { | ||
var layers = {}; | ||
for (var k in layerDefs) { | ||
if (layerDefs.hasOwnProperty(k)) { | ||
layers[k] = (LeafletTileLayerDefinition.createTileLayer(layerDefs[k])); | ||
} | ||
} | ||
} | ||
return layers; | ||
}; | ||
/** | ||
* Create a Tile Layer from the current state of this object | ||
* | ||
* @returns {TileLayer} A new TileLayer | ||
*/ | ||
/** | ||
return layers; | ||
}; | ||
/** | ||
* Create a Tile Layer from the current state of this object | ||
@@ -947,21 +820,16 @@ * | ||
*/ | ||
LeafletTileLayerDefinition.prototype.createTileLayer = /** | ||
* Create a Tile Layer from the current state of this object | ||
* | ||
* @returns {TileLayer} A new TileLayer | ||
*/ | ||
function () { | ||
return LeafletTileLayerDefinition.createTileLayer(this); | ||
}; | ||
return LeafletTileLayerDefinition; | ||
}()); | ||
LeafletTileLayerDefinition.prototype.createTileLayer = function () { | ||
return LeafletTileLayerDefinition.createTileLayer(this); | ||
}; | ||
return LeafletTileLayerDefinition; | ||
}()); | ||
exports.LeafletModule = LeafletModule; | ||
exports.LeafletDirective = LeafletDirective; | ||
exports.LeafletDirectiveWrapper = LeafletDirectiveWrapper; | ||
exports.LeafletTileLayerDefinition = LeafletTileLayerDefinition; | ||
exports.LeafletModule = LeafletModule; | ||
exports.LeafletDirective = LeafletDirective; | ||
exports.LeafletDirectiveWrapper = LeafletDirectiveWrapper; | ||
exports.LeafletTileLayerDefinition = LeafletTileLayerDefinition; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
//# sourceMappingURL=ngx-leaflet.js.map |
@@ -1,199 +0,123 @@ | ||
/*! @asymmetrik/ngx-leaflet - 3.1.0 - Copyright Asymmetrik, Ltd. 2007-2018 - All Rights Reserved. + */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("leaflet")):"function"==typeof define&&define.amd?define(["exports","@angular/core","leaflet"],t):t(e.ngxLeaflet={},e.ng.core,e.L)}(this,function(e,o,a){"use strict";var r=/** @class */function(){function e(){}return e.mapToArray=function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(e[n]);return t},e.handleEvent=function(e,t,n){ | ||
/*! @asymmetrik/ngx-leaflet - 4.0.0 - Copyright Asymmetrik, Ltd. 2007-2018 - All Rights Reserved. + */ | ||
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@angular/core"),require("leaflet")):typeof define==="function"&&define.amd?define(["exports","@angular/core","leaflet"],factory):factory(global.ngxLeaflet={},global.ng.core,global.L)})(this,function(exports,core,leaflet){"use strict";var LeafletUtil=/** @class */function(){function LeafletUtil(){}LeafletUtil.mapToArray=function(map){var toReturn=[];for(var k in map){if(map.hasOwnProperty(k)){toReturn.push(map[k])}}return toReturn};LeafletUtil.handleEvent=function(zone,eventEmitter,event){ | ||
// Don't want to emit if there are no observers | ||
0<t.observers.length&&e.run(function(){t.emit(n)})},e}(),t=/** @class */function(){function e(e,t){ | ||
// Nothing here | ||
this.element=e,this.zone=t,this.DEFAULT_ZOOM=1,this.DEFAULT_CENTER=a.latLng(38.907192,-77.036871),this.DEFAULT_FPZ_OPTIONS={},this.fitBoundsOptions=this.DEFAULT_FPZ_OPTIONS,this.panOptions=this.DEFAULT_FPZ_OPTIONS,this.zoomOptions=this.DEFAULT_FPZ_OPTIONS,this.zoomPanOptions=this.DEFAULT_FPZ_OPTIONS, | ||
if(0<eventEmitter.observers.length){zone.run(function(){eventEmitter.emit(event)})}};return LeafletUtil}();var LeafletDirective=/** @class */function(){function LeafletDirective(element,zone){this.element=element;this.zone=zone;this.DEFAULT_ZOOM=1;this.DEFAULT_CENTER=leaflet.latLng(38.907192,-77.036871);this.DEFAULT_FPZ_OPTIONS={};this.fitBoundsOptions=this.DEFAULT_FPZ_OPTIONS;this.panOptions=this.DEFAULT_FPZ_OPTIONS;this.zoomOptions=this.DEFAULT_FPZ_OPTIONS;this.zoomPanOptions=this.DEFAULT_FPZ_OPTIONS; | ||
// Default configuration | ||
this.options={}, | ||
this.options={}; | ||
// Configure callback function for the map | ||
this.mapReady=new o.EventEmitter,this.zoomChange=new o.EventEmitter,this.centerChange=new o.EventEmitter, | ||
this.mapReady=new core.EventEmitter;this.zoomChange=new core.EventEmitter;this.centerChange=new core.EventEmitter; | ||
// Mouse Map Events | ||
this.onClick=new o.EventEmitter,this.onDoubleClick=new o.EventEmitter,this.onMouseDown=new o.EventEmitter,this.onMouseUp=new o.EventEmitter,this.onMouseMove=new o.EventEmitter,this.onMouseOver=new o.EventEmitter, | ||
this.onClick=new core.EventEmitter;this.onDoubleClick=new core.EventEmitter;this.onMouseDown=new core.EventEmitter;this.onMouseUp=new core.EventEmitter;this.onMouseMove=new core.EventEmitter;this.onMouseOver=new core.EventEmitter; | ||
// Map Move Events | ||
this.onMapMove=new o.EventEmitter,this.onMapMoveStart=new o.EventEmitter,this.onMapMoveEnd=new o.EventEmitter, | ||
this.onMapMove=new core.EventEmitter;this.onMapMoveStart=new core.EventEmitter;this.onMapMoveEnd=new core.EventEmitter; | ||
// Map Zoom Events | ||
this.onMapZoom=new o.EventEmitter,this.onMapZoomStart=new o.EventEmitter,this.onMapZoomEnd=new o.EventEmitter}return e.prototype.ngOnInit=function(){var e=this; | ||
this.onMapZoom=new core.EventEmitter;this.onMapZoomStart=new core.EventEmitter;this.onMapZoomEnd=new core.EventEmitter; | ||
// Nothing here | ||
}LeafletDirective.prototype.ngOnInit=function(){var _this=this; | ||
// Create the map outside of angular so the various map events don't trigger change detection | ||
this.zone.runOutsideAngular(function(){ | ||
// Create the map with some reasonable defaults | ||
// Create the map with some reasonable defaults | ||
e.map=a.map(e.element.nativeElement,e.options),e.addMapEventListeners()}), | ||
_this.map=leaflet.map(_this.element.nativeElement,_this.options);_this.addMapEventListeners()}); | ||
// Only setView if there is a center/zoom | ||
null!=this.center&&null!=this.zoom&&this.setView(this.center,this.zoom), | ||
if(null!=this.center&&null!=this.zoom){this.setView(this.center,this.zoom)} | ||
// Set up all the initial settings | ||
null!=this.fitBounds&&this.setFitBounds(this.fitBounds),null!=this.maxBounds&&this.setMaxBounds(this.maxBounds),null!=this.minZoom&&this.setMinZoom(this.minZoom),null!=this.maxZoom&&this.setMaxZoom(this.maxZoom),this.doResize(), | ||
if(null!=this.fitBounds){this.setFitBounds(this.fitBounds)}if(null!=this.maxBounds){this.setMaxBounds(this.maxBounds)}if(null!=this.minZoom){this.setMinZoom(this.minZoom)}if(null!=this.maxZoom){this.setMaxZoom(this.maxZoom)}this.doResize(); | ||
// Fire map ready event | ||
this.mapReady.emit(this.map)},e.prototype.ngOnChanges=function(e){ | ||
this.mapReady.emit(this.map)};LeafletDirective.prototype.ngOnChanges=function(changes){ | ||
/* | ||
* The following code is to address an issue with our (basic) implementation of | ||
* zooming and panning. From our testing, it seems that a pan operation followed | ||
* by a zoom operation in the same thread will interfere with eachother. The zoom | ||
* operation interrupts/cancels the pan, resulting in a final center point that is | ||
* inaccurate. The solution seems to be to either separate them with a timeout or | ||
* to collapse them into a setView call. | ||
*/ | ||
* The following code is to address an issue with our (basic) implementation of | ||
* zooming and panning. From our testing, it seems that a pan operation followed | ||
* by a zoom operation in the same thread will interfere with eachother. The zoom | ||
* operation interrupts/cancels the pan, resulting in a final center point that is | ||
* inaccurate. The solution seems to be to either separate them with a timeout or | ||
* to collapse them into a setView call. | ||
*/ | ||
// Zooming and Panning | ||
e.zoom&&e.center&&null!=this.zoom&&null!=this.center?this.setView(e.center.currentValue,e.zoom.currentValue):e.zoom?this.setZoom(e.zoom.currentValue):e.center&&this.setCenter(e.center.currentValue), | ||
if(changes["zoom"]&&changes["center"]&&null!=this.zoom&&null!=this.center){this.setView(changes["center"].currentValue,changes["zoom"].currentValue)}else if(changes["zoom"]){this.setZoom(changes["zoom"].currentValue)}else if(changes["center"]){this.setCenter(changes["center"].currentValue)} | ||
// Other options | ||
e.fitBounds&&this.setFitBounds(e.fitBounds.currentValue),e.maxBounds&&this.setMaxBounds(e.maxBounds.currentValue),e.minZoom&&this.setMinZoom(e.minZoom.currentValue),e.maxZoom&&this.setMaxZoom(e.maxZoom.currentValue)},e.prototype.getMap=function(){return this.map},e.prototype.onResize=function(){this.delayResize()},e.prototype.addMapEventListeners=function(){var n=this; | ||
if(changes["fitBounds"]){this.setFitBounds(changes["fitBounds"].currentValue)}if(changes["maxBounds"]){this.setMaxBounds(changes["maxBounds"].currentValue)}if(changes["minZoom"]){this.setMinZoom(changes["minZoom"].currentValue)}if(changes["maxZoom"]){this.setMaxZoom(changes["maxZoom"].currentValue)}};LeafletDirective.prototype.getMap=function(){return this.map};LeafletDirective.prototype.onResize=function(){this.delayResize()};LeafletDirective.prototype.addMapEventListeners=function(){var _this=this; | ||
// Add all the pass-through mouse event handlers | ||
this.map.on("click",function(e){return r.handleEvent(n.zone,n.onClick,e)}),this.map.on("dblclick",function(e){return r.handleEvent(n.zone,n.onDoubleClick,e)}),this.map.on("mousedown",function(e){return r.handleEvent(n.zone,n.onMouseDown,e)}),this.map.on("mouseup",function(e){return r.handleEvent(n.zone,n.onMouseUp,e)}),this.map.on("mouseover",function(e){return r.handleEvent(n.zone,n.onMouseOver,e)}),this.map.on("mousemove",function(e){return r.handleEvent(n.zone,n.onMouseMove,e)}),this.map.on("zoomstart",function(e){return r.handleEvent(n.zone,n.onMapZoomStart,e)}),this.map.on("zoom",function(e){return r.handleEvent(n.zone,n.onMapZoom,e)}),this.map.on("zoomend",function(e){return r.handleEvent(n.zone,n.onMapZoomEnd,e)}),this.map.on("movestart",function(e){return r.handleEvent(n.zone,n.onMapMoveStart,e)}),this.map.on("move",function(e){return r.handleEvent(n.zone,n.onMapMove,e)}),this.map.on("moveend",function(e){return r.handleEvent(n.zone,n.onMapMoveEnd,e)}), | ||
this.map.on("click",function(e){return LeafletUtil.handleEvent(_this.zone,_this.onClick,e)});this.map.on("dblclick",function(e){return LeafletUtil.handleEvent(_this.zone,_this.onDoubleClick,e)});this.map.on("mousedown",function(e){return LeafletUtil.handleEvent(_this.zone,_this.onMouseDown,e)});this.map.on("mouseup",function(e){return LeafletUtil.handleEvent(_this.zone,_this.onMouseUp,e)});this.map.on("mouseover",function(e){return LeafletUtil.handleEvent(_this.zone,_this.onMouseOver,e)});this.map.on("mousemove",function(e){return LeafletUtil.handleEvent(_this.zone,_this.onMouseMove,e)});this.map.on("zoomstart",function(e){return LeafletUtil.handleEvent(_this.zone,_this.onMapZoomStart,e)});this.map.on("zoom",function(e){return LeafletUtil.handleEvent(_this.zone,_this.onMapZoom,e)});this.map.on("zoomend",function(e){return LeafletUtil.handleEvent(_this.zone,_this.onMapZoomEnd,e)});this.map.on("movestart",function(e){return LeafletUtil.handleEvent(_this.zone,_this.onMapMoveStart,e)});this.map.on("move",function(e){return LeafletUtil.handleEvent(_this.zone,_this.onMapMove,e)});this.map.on("moveend",function(e){return LeafletUtil.handleEvent(_this.zone,_this.onMapMoveEnd,e)}); | ||
// Update any things for which we provide output bindings | ||
this.map.on("zoomend moveend",function(){var e=n.map.getZoom();e!==n.zoom&&(n.zoom=e,r.handleEvent(n.zone,n.zoomChange,e));var t=n.map.getCenter();null==t&&null==n.center||(null!=t&&null!=n.center||t===n.center)&&t.lat===n.center.lat&&t.lng===n.center.lng||(n.center=t,r.handleEvent(n.zone,n.centerChange,t))})}, | ||
this.map.on("zoomend moveend",function(){var zoom=_this.map.getZoom();if(zoom!==_this.zoom){_this.zoom=zoom;LeafletUtil.handleEvent(_this.zone,_this.zoomChange,zoom)}var center=_this.map.getCenter();if(null!=center||null!=_this.center){if((null==center||null==_this.center)&¢er!==_this.center||(center.lat!==_this.center.lat||center.lng!==_this.center.lng)){_this.center=center;LeafletUtil.handleEvent(_this.zone,_this.centerChange,center)}}})}; | ||
/** | ||
* Resize the map to fit it's parent container | ||
*/ | ||
/** | ||
* Resize the map to fit it's parent container | ||
*/ | ||
e.prototype.doResize= | ||
/** | ||
* Resize the map to fit it's parent container | ||
*/ | ||
function(){var e=this; | ||
*/LeafletDirective.prototype.doResize=function(){var _this=this; | ||
// Run this outside of angular so the map events stay outside of angular | ||
this.zone.runOutsideAngular(function(){ | ||
// Invalidate the map size to trigger it to update itself | ||
// Invalidate the map size to trigger it to update itself | ||
e.map.invalidateSize({})})}, | ||
_this.map.invalidateSize({})})}; | ||
/** | ||
* Manage a delayed resize of the component | ||
*/ | ||
/** | ||
* Manage a delayed resize of the component | ||
*/ | ||
e.prototype.delayResize= | ||
*/LeafletDirective.prototype.delayResize=function(){if(null!=this.resizeTimer){clearTimeout(this.resizeTimer)}this.resizeTimer=setTimeout(this.doResize.bind(this),200)}; | ||
/** | ||
* Manage a delayed resize of the component | ||
*/ | ||
function(){null!=this.resizeTimer&&clearTimeout(this.resizeTimer),this.resizeTimer=setTimeout(this.doResize.bind(this),200)}, | ||
/** | ||
* Set the view (center/zoom) all at once | ||
* @param center The new center | ||
* @param zoom The new zoom level | ||
*/ | ||
/** | ||
* Set the view (center/zoom) all at once | ||
* @param center The new center | ||
* @param zoom The new zoom level | ||
*/ | ||
e.prototype.setView= | ||
*/LeafletDirective.prototype.setView=function(center,zoom){if(this.map&&null!=center&&null!=zoom){this.map.setView(center,zoom,this.zoomPanOptions)}}; | ||
/** | ||
* Set the view (center/zoom) all at once | ||
* @param center The new center | ||
* @param zoom The new zoom level | ||
*/ | ||
function(e,t){this.map&&null!=e&&null!=t&&this.map.setView(e,t,this.zoomPanOptions)}, | ||
/** | ||
* Set the map zoom level | ||
* @param zoom the new zoom level for the map | ||
*/ | ||
/** | ||
* Set the map zoom level | ||
* @param zoom the new zoom level for the map | ||
*/ | ||
e.prototype.setZoom= | ||
*/LeafletDirective.prototype.setZoom=function(zoom){if(this.map&&null!=zoom){this.map.setZoom(zoom,this.zoomOptions)}}; | ||
/** | ||
* Set the map zoom level | ||
* @param zoom the new zoom level for the map | ||
*/ | ||
function(e){this.map&&null!=e&&this.map.setZoom(e,this.zoomOptions)}, | ||
/** | ||
* Set the center of the map | ||
* @param center the center point | ||
*/ | ||
/** | ||
* Set the center of the map | ||
* @param center the center point | ||
*/ | ||
e.prototype.setCenter= | ||
*/LeafletDirective.prototype.setCenter=function(center){if(this.map&&null!=center){this.map.panTo(center,this.panOptions)}}; | ||
/** | ||
* Set the center of the map | ||
* @param center the center point | ||
*/ | ||
function(e){this.map&&null!=e&&this.map.panTo(e,this.panOptions)}, | ||
/** | ||
* Fit the map to the bounds | ||
* @param latLngBounds the boundary to set | ||
*/ | ||
/** | ||
* Fit the map to the bounds | ||
* @param latLngBounds the boundary to set | ||
*/ | ||
e.prototype.setFitBounds= | ||
*/LeafletDirective.prototype.setFitBounds=function(latLngBounds){if(this.map&&null!=latLngBounds){this.map.fitBounds(latLngBounds,this.fitBoundsOptions)}}; | ||
/** | ||
* Fit the map to the bounds | ||
* @param latLngBounds the boundary to set | ||
*/ | ||
function(e){this.map&&null!=e&&this.map.fitBounds(e,this.fitBoundsOptions)}, | ||
/** | ||
* Set the map's max bounds | ||
* @param latLngBounds the boundary to set | ||
*/ | ||
/** | ||
* Set the map's max bounds | ||
* @param latLngBounds the boundary to set | ||
*/ | ||
e.prototype.setMaxBounds= | ||
*/LeafletDirective.prototype.setMaxBounds=function(latLngBounds){if(this.map&&null!=latLngBounds){this.map.setMaxBounds(latLngBounds)}}; | ||
/** | ||
* Set the map's max bounds | ||
* @param latLngBounds the boundary to set | ||
*/ | ||
function(e){this.map&&null!=e&&this.map.setMaxBounds(e)}, | ||
/** | ||
* Set the map's min zoom | ||
* @param number the new min zoom | ||
*/ | ||
/** | ||
* Set the map's min zoom | ||
* @param number the new min zoom | ||
*/ | ||
e.prototype.setMinZoom= | ||
*/LeafletDirective.prototype.setMinZoom=function(zoom){if(this.map&&null!=zoom){this.map.setMinZoom(zoom)}}; | ||
/** | ||
* Set the map's min zoom | ||
* @param number the new min zoom | ||
*/ | ||
function(e){this.map&&null!=e&&this.map.setMinZoom(e)}, | ||
*/LeafletDirective.prototype.setMaxZoom=function(zoom){if(this.map&&null!=zoom){this.map.setMaxZoom(zoom)}};LeafletDirective.decorators=[{type:core.Directive,args:[{selector:"[leaflet]"}]}]; | ||
/** @nocollapse */LeafletDirective.ctorParameters=function(){return[{type:core.ElementRef},{type:core.NgZone}]};LeafletDirective.propDecorators={fitBoundsOptions:[{type:core.Input,args:["leafletFitBoundsOptions"]}],panOptions:[{type:core.Input,args:["leafletPanOptions"]}],zoomOptions:[{type:core.Input,args:["leafletZoomOptions"]}],zoomPanOptions:[{type:core.Input,args:["leafletZoomPanOptions"]}],options:[{type:core.Input,args:["leafletOptions"]}],mapReady:[{type:core.Output,args:["leafletMapReady"]}],zoom:[{type:core.Input,args:["leafletZoom"]}],zoomChange:[{type:core.Output,args:["leafletZoomChange"]}],center:[{type:core.Input,args:["leafletCenter"]}],centerChange:[{type:core.Output,args:["leafletCenterChange"]}],fitBounds:[{type:core.Input,args:["leafletFitBounds"]}],maxBounds:[{type:core.Input,args:["leafletMaxBounds"]}],minZoom:[{type:core.Input,args:["leafletMinZoom"]}],maxZoom:[{type:core.Input,args:["leafletMaxZoom"]}],onClick:[{type:core.Output,args:["leafletClick"]}],onDoubleClick:[{type:core.Output,args:["leafletDoubleClick"]}],onMouseDown:[{type:core.Output,args:["leafletMouseDown"]}],onMouseUp:[{type:core.Output,args:["leafletMouseUp"]}],onMouseMove:[{type:core.Output,args:["leafletMouseMove"]}],onMouseOver:[{type:core.Output,args:["leafletMouseOver"]}],onMapMove:[{type:core.Output,args:["leafletMapMove"]}],onMapMoveStart:[{type:core.Output,args:["leafletMapMoveStart"]}],onMapMoveEnd:[{type:core.Output,args:["leafletMapMoveEnd"]}],onMapZoom:[{type:core.Output,args:["leafletMapZoom"]}],onMapZoomStart:[{type:core.Output,args:["leafletMapZoomStart"]}],onMapZoomEnd:[{type:core.Output,args:["leafletMapZoomEnd"]}],onResize:[{type:core.HostListener,args:["window:resize",[]]}]};return LeafletDirective}();var LeafletDirectiveWrapper=/** @class */function(){function LeafletDirectiveWrapper(leafletDirective){this.leafletDirective=leafletDirective}LeafletDirectiveWrapper.prototype.init=function(){ | ||
// Nothing for now | ||
};LeafletDirectiveWrapper.prototype.getMap=function(){return this.leafletDirective.getMap()};return LeafletDirectiveWrapper}(); | ||
/** | ||
* Set the map's min zoom | ||
* @param number the new min zoom | ||
*/ | ||
/** | ||
* Set the map's min zoom | ||
* @param number the new min zoom | ||
*/ | ||
e.prototype.setMaxZoom= | ||
/** | ||
* Set the map's min zoom | ||
* @param number the new min zoom | ||
*/ | ||
function(e){this.map&&null!=e&&this.map.setMaxZoom(e)},e.decorators=[{type:o.Directive,args:[{selector:"[leaflet]"}]}], | ||
/** @nocollapse */ | ||
e.ctorParameters=function(){return[{type:o.ElementRef},{type:o.NgZone}]},e.propDecorators={fitBoundsOptions:[{type:o.Input,args:["leafletFitBoundsOptions"]}],panOptions:[{type:o.Input,args:["leafletPanOptions"]}],zoomOptions:[{type:o.Input,args:["leafletZoomOptions"]}],zoomPanOptions:[{type:o.Input,args:["leafletZoomPanOptions"]}],options:[{type:o.Input,args:["leafletOptions"]}],mapReady:[{type:o.Output,args:["leafletMapReady"]}],zoom:[{type:o.Input,args:["leafletZoom"]}],zoomChange:[{type:o.Output,args:["leafletZoomChange"]}],center:[{type:o.Input,args:["leafletCenter"]}],centerChange:[{type:o.Output,args:["leafletCenterChange"]}],fitBounds:[{type:o.Input,args:["leafletFitBounds"]}],maxBounds:[{type:o.Input,args:["leafletMaxBounds"]}],minZoom:[{type:o.Input,args:["leafletMinZoom"]}],maxZoom:[{type:o.Input,args:["leafletMaxZoom"]}],onClick:[{type:o.Output,args:["leafletClick"]}],onDoubleClick:[{type:o.Output,args:["leafletDoubleClick"]}],onMouseDown:[{type:o.Output,args:["leafletMouseDown"]}],onMouseUp:[{type:o.Output,args:["leafletMouseUp"]}],onMouseMove:[{type:o.Output,args:["leafletMouseMove"]}],onMouseOver:[{type:o.Output,args:["leafletMouseOver"]}],onMapMove:[{type:o.Output,args:["leafletMapMove"]}],onMapMoveStart:[{type:o.Output,args:["leafletMapMoveStart"]}],onMapMoveEnd:[{type:o.Output,args:["leafletMapMoveEnd"]}],onMapZoom:[{type:o.Output,args:["leafletMapZoom"]}],onMapZoomStart:[{type:o.Output,args:["leafletMapZoomStart"]}],onMapZoomEnd:[{type:o.Output,args:["leafletMapZoomEnd"]}],onResize:[{type:o.HostListener,args:["window:resize",[]]}]},e}(),s=/** @class */function(){function e(e){this.leafletDirective=e}return e.prototype.init=function(){ | ||
// Nothing for now | ||
},e.prototype.getMap=function(){return this.leafletDirective.getMap()},e}(),n=/** @class */function(){function e(e,t){this.zone=t, | ||
* Layer directive | ||
* | ||
* This directive is used to directly control a single map layer. The purpose of this directive is to | ||
* be used as part of a child structural directive of the map element. | ||
* | ||
*/var LeafletLayerDirective=/** @class */function(){function LeafletLayerDirective(leafletDirective,zone){this.zone=zone; | ||
// Layer Events | ||
this.onAdd=new o.EventEmitter,this.onRemove=new o.EventEmitter,this.leafletDirective=new s(e)}return e.prototype.ngOnInit=function(){ | ||
this.onAdd=new core.EventEmitter;this.onRemove=new core.EventEmitter;this.leafletDirective=new LeafletDirectiveWrapper(leafletDirective)}LeafletLayerDirective.prototype.ngOnInit=function(){ | ||
// Init the map | ||
this.leafletDirective.init()},e.prototype.ngOnDestroy=function(){this.layer.remove()},e.prototype.ngOnChanges=function(e){var t=this;if(e.layer){ | ||
this.leafletDirective.init()};LeafletLayerDirective.prototype.ngOnDestroy=function(){this.layer.remove()};LeafletLayerDirective.prototype.ngOnChanges=function(changes){var _this=this;if(changes["layer"]){ | ||
// Update the layer | ||
var n=e.layer.previousValue,o=e.layer.currentValue;this.zone.runOutsideAngular(function(){null!=n&&n.remove(),null!=o&&(t.addLayerEventListeners(o),t.leafletDirective.getMap().addLayer(o))})}},e.prototype.addLayerEventListeners=function(e){var t=this;e.on("add",function(e){return r.handleEvent(t.zone,t.onAdd,e)}),e.on("remove",function(e){return r.handleEvent(t.zone,t.onRemove,e)})},e.decorators=[{type:o.Directive,args:[{selector:"[leafletLayer]"}]}], | ||
/** @nocollapse */ | ||
e.ctorParameters=function(){return[{type:t},{type:o.NgZone}]},e.propDecorators={layer:[{type:o.Input,args:["leafletLayer"]}],onAdd:[{type:o.Output,args:["leafletLayerAdd"]}],onRemove:[{type:o.Output,args:["leafletLayerRemove"]}]},e}(),i=/** @class */function(){function e(e,t,n){this.differs=t,this.zone=n,this.leafletDirective=new s(e),this.layersDiffer=this.differs.find([]).create()}return Object.defineProperty(e.prototype,"layers",{get:function(){return this.layersValue},set: | ||
var p_1=changes["layer"].previousValue;var n_1=changes["layer"].currentValue;this.zone.runOutsideAngular(function(){if(null!=p_1){p_1.remove()}if(null!=n_1){_this.addLayerEventListeners(n_1);_this.leafletDirective.getMap().addLayer(n_1)}})}};LeafletLayerDirective.prototype.addLayerEventListeners=function(l){var _this=this;l.on("add",function(e){return LeafletUtil.handleEvent(_this.zone,_this.onAdd,e)});l.on("remove",function(e){return LeafletUtil.handleEvent(_this.zone,_this.onRemove,e)})};LeafletLayerDirective.decorators=[{type:core.Directive,args:[{selector:"[leafletLayer]"}]}]; | ||
/** @nocollapse */LeafletLayerDirective.ctorParameters=function(){return[{type:LeafletDirective},{type:core.NgZone}]};LeafletLayerDirective.propDecorators={layer:[{type:core.Input,args:["leafletLayer"]}],onAdd:[{type:core.Output,args:["leafletLayerAdd"]}],onRemove:[{type:core.Output,args:["leafletLayerRemove"]}]};return LeafletLayerDirective}(); | ||
/** | ||
* Layers directive | ||
* | ||
* This directive is used to directly control map layers. As changes are made to the input array of | ||
* layers, the map is synched to the array. As layers are added or removed from the input array, they | ||
* are also added or removed from the map. The input array is treated as immutable. To detect changes, | ||
* you must change the array instance. | ||
* | ||
* Important Note: The input layers array is assumed to be immutable. This means you need to use an | ||
* immutable array implementation or create a new copy of your array when you make changes, otherwise | ||
* this directive won't detect the change. This is by design. It's for performance reasons. Change | ||
* detection of mutable arrays requires diffing the state of the array on every DoCheck cycle, which | ||
* is extremely expensive from a time complexity perspective. | ||
* | ||
*/var LeafletLayersDirective=/** @class */function(){function LeafletLayersDirective(leafletDirective,differs,zone){this.differs=differs;this.zone=zone;this.leafletDirective=new LeafletDirectiveWrapper(leafletDirective);this.layersDiffer=this.differs.find([]).create()}Object.defineProperty(LeafletLayersDirective.prototype,"layers",{get:function(){return this.layersValue}, | ||
// Set/get the layers | ||
function(e){this.layersValue=e, | ||
set:function(v){this.layersValue=v; | ||
// Now that we have a differ, do an immediate layer update | ||
this.updateLayers()},enumerable:!0,configurable:!0}),e.prototype.ngDoCheck=function(){this.updateLayers()},e.prototype.ngOnInit=function(){ | ||
this.updateLayers()},enumerable:true,configurable:true});LeafletLayersDirective.prototype.ngDoCheck=function(){this.updateLayers()};LeafletLayersDirective.prototype.ngOnInit=function(){ | ||
// Init the map | ||
this.leafletDirective.init(), | ||
this.leafletDirective.init(); | ||
// Update layers once the map is ready | ||
this.updateLayers()},e.prototype.ngOnDestroy=function(){this.layers=[]}, | ||
this.updateLayers()};LeafletLayersDirective.prototype.ngOnDestroy=function(){this.layers=[]}; | ||
/** | ||
* Update the state of the layers. | ||
* We use an iterable differ to synchronize the map layers with the state of the bound layers array. | ||
* This is important because it allows us to react to changes to the contents of the array as well | ||
* as changes to the actual array instance. | ||
*/ | ||
/** | ||
* Update the state of the layers. | ||
@@ -203,82 +127,75 @@ * We use an iterable differ to synchronize the map layers with the state of the bound layers array. | ||
* as changes to the actual array instance. | ||
*/ | ||
e.prototype.updateLayers= | ||
/** | ||
* Update the state of the layers. | ||
* We use an iterable differ to synchronize the map layers with the state of the bound layers array. | ||
* This is important because it allows us to react to changes to the contents of the array as well | ||
* as changes to the actual array instance. | ||
*/ | ||
function(){var t=this.leafletDirective.getMap();if(null!=t&&null!=this.layersDiffer){var e=this.layersDiffer.diff(this.layersValue);null!=e&& | ||
*/LeafletLayersDirective.prototype.updateLayers=function(){var map=this.leafletDirective.getMap();if(null!=map&&null!=this.layersDiffer){var changes_1=this.layersDiffer.diff(this.layersValue);if(null!=changes_1){ | ||
// Run outside angular to ensure layer events don't trigger change detection | ||
this.zone.runOutsideAngular(function(){e.forEachRemovedItem(function(e){t.removeLayer(e.item)}),e.forEachAddedItem(function(e){t.addLayer(e.item)})})}},e.decorators=[{type:o.Directive,args:[{selector:"[leafletLayers]"}]}], | ||
/** @nocollapse */ | ||
e.ctorParameters=function(){return[{type:t},{type:o.IterableDiffers},{type:o.NgZone}]},e.propDecorators={layers:[{type:o.Input,args:["leafletLayers"]}]},e}(),l=/** @class */function(){function e(){this.layersRemoved=0,this.layersChanged=0,this.layersAdded=0}return e.prototype.changed=function(){return!(0===this.layersRemoved&&0===this.layersChanged&&0===this.layersAdded)},e}(),u=/** @class */function(){function e(e,t){this.zone=e,this.layersControlReady=t}return e.prototype.getLayersControl=function(){return this.layersControl},e.prototype.init=function(e,t){var n=this,o=e.baseLayers||{},r=e.overlays||{}; | ||
this.zone.runOutsideAngular(function(){changes_1.forEachRemovedItem(function(c){map.removeLayer(c.item)});changes_1.forEachAddedItem(function(c){map.addLayer(c.item)})})}}};LeafletLayersDirective.decorators=[{type:core.Directive,args:[{selector:"[leafletLayers]"}]}]; | ||
/** @nocollapse */LeafletLayersDirective.ctorParameters=function(){return[{type:LeafletDirective},{type:core.IterableDiffers},{type:core.NgZone}]};LeafletLayersDirective.propDecorators={layers:[{type:core.Input,args:["leafletLayers"]}]};return LeafletLayersDirective}();var LeafletControlLayersChanges=/** @class */function(){function LeafletControlLayersChanges(){this.layersRemoved=0;this.layersChanged=0;this.layersAdded=0}LeafletControlLayersChanges.prototype.changed=function(){return!(this.layersRemoved===0&&this.layersChanged===0&&this.layersAdded===0)};return LeafletControlLayersChanges}();var LeafletControlLayersWrapper=/** @class */function(){function LeafletControlLayersWrapper(zone,layersControlReady){this.zone=zone;this.layersControlReady=layersControlReady}LeafletControlLayersWrapper.prototype.getLayersControl=function(){return this.layersControl};LeafletControlLayersWrapper.prototype.init=function(controlConfig,controlOptions){var _this=this;var baseLayers=controlConfig.baseLayers||{};var overlays=controlConfig.overlays||{}; | ||
// Create the control outside of angular to ensure events don't trigger change detection | ||
return this.zone.runOutsideAngular(function(){n.layersControl=a.control.layers(o,r,t)}),this.layersControlReady.emit(this.layersControl),this.layersControl},e.prototype.applyBaseLayerChanges=function(e){var t=new l;return null!=this.layersControl&&(t=this.applyChanges(e,this.layersControl.addBaseLayer)),t},e.prototype.applyOverlayChanges=function(e){var t=new l;return null!=this.layersControl&&(t=this.applyChanges(e,this.layersControl.addOverlay)),t},e.prototype.applyChanges=function(e,t){var n=this,o=new l;return null!=e&& | ||
this.zone.runOutsideAngular(function(){_this.layersControl=leaflet.control.layers(baseLayers,overlays,controlOptions)});this.layersControlReady.emit(this.layersControl);return this.layersControl};LeafletControlLayersWrapper.prototype.applyBaseLayerChanges=function(changes){var results=new LeafletControlLayersChanges;if(null!=this.layersControl){results=this.applyChanges(changes,this.layersControl.addBaseLayer)}return results};LeafletControlLayersWrapper.prototype.applyOverlayChanges=function(changes){var results=new LeafletControlLayersChanges;if(null!=this.layersControl){results=this.applyChanges(changes,this.layersControl.addOverlay)}return results};LeafletControlLayersWrapper.prototype.applyChanges=function(changes,addFn){var _this=this;var results=new LeafletControlLayersChanges;if(null!=changes){ | ||
// All layer management is outside angular to avoid layer events from triggering change detection | ||
this.zone.runOutsideAngular(function(){e.forEachChangedItem(function(e){n.layersControl.removeLayer(e.previousValue),t.call(n.layersControl,e.currentValue,e.key),o.layersChanged++}),e.forEachRemovedItem(function(e){n.layersControl.removeLayer(e.previousValue),o.layersRemoved++}),e.forEachAddedItem(function(e){t.call(n.layersControl,e.currentValue,e.key),o.layersAdded++})}),o},e}(),p=function(){this.baseLayers={},this.overlays={}},y=/** @class */function(){function e(e,t,n){this.differs=t,this.zone=n,this.layersControlReady=new o.EventEmitter,this.leafletDirective=new s(e),this.controlLayers=new u(this.zone,this.layersControlReady), | ||
this.zone.runOutsideAngular(function(){changes.forEachChangedItem(function(c){_this.layersControl.removeLayer(c.previousValue);addFn.call(_this.layersControl,c.currentValue,c.key);results.layersChanged++});changes.forEachRemovedItem(function(c){_this.layersControl.removeLayer(c.previousValue);results.layersRemoved++});changes.forEachAddedItem(function(c){addFn.call(_this.layersControl,c.currentValue,c.key);results.layersAdded++})})}return results};return LeafletControlLayersWrapper}();var LeafletControlLayersConfig=/** @class */function(){function LeafletControlLayersConfig(){this.baseLayers={};this.overlays={}}return LeafletControlLayersConfig}(); | ||
/** | ||
* Layers Control | ||
* | ||
* This directive is used to configure the layers control. The input accepts an object with two | ||
* key-value maps of layer name -> layer. Mutable changes are detected. On changes, a differ is | ||
* used to determine what changed so that layers are appropriately added or removed. | ||
* | ||
* To specify which layer to show as the 'active' baselayer, you will want to add it to the map | ||
* using the layers directive. Otherwise, the last one it sees will be used. | ||
*/var LeafletLayersControlDirective=/** @class */function(){function LeafletLayersControlDirective(leafletDirective,differs,zone){this.differs=differs;this.zone=zone;this.layersControlReady=new core.EventEmitter;this.leafletDirective=new LeafletDirectiveWrapper(leafletDirective);this.controlLayers=new LeafletControlLayersWrapper(this.zone,this.layersControlReady); | ||
// Generate differs | ||
this.baseLayersDiffer=this.differs.find({}).create(),this.overlaysDiffer=this.differs.find({}).create()}return Object.defineProperty(e.prototype,"layersControlConfig",{get:function(){return this.layersControlConfigValue},set:function(e){ | ||
this.baseLayersDiffer=this.differs.find({}).create();this.overlaysDiffer=this.differs.find({}).create()}Object.defineProperty(LeafletLayersControlDirective.prototype,"layersControlConfig",{get:function(){return this.layersControlConfigValue},set:function(v){ | ||
// Validation/init stuff | ||
null==e&&(e=new p),null==e.baseLayers&&(e.baseLayers={}),null==e.overlays&&(e.overlays={}), | ||
if(null==v){v=new LeafletControlLayersConfig}if(null==v.baseLayers){v.baseLayers={}}if(null==v.overlays){v.overlays={}} | ||
// Store the value | ||
this.layersControlConfigValue=e, | ||
this.layersControlConfigValue=v; | ||
// Update the map | ||
this.updateLayers()},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){var e=this; | ||
this.updateLayers()},enumerable:true,configurable:true});LeafletLayersControlDirective.prototype.ngOnInit=function(){var _this=this; | ||
// Init the map | ||
this.leafletDirective.init(), | ||
this.leafletDirective.init(); | ||
// Set up control outside of angular to avoid change detection when using the control | ||
this.zone.runOutsideAngular(function(){ | ||
// Set up all the initial settings | ||
// Set up all the initial settings | ||
e.controlLayers.init({},e.layersControlOptions).addTo(e.leafletDirective.getMap())}),this.updateLayers()},e.prototype.ngOnDestroy=function(){this.layersControlConfig={baseLayers:{},overlays:{}},this.controlLayers.getLayersControl().remove()},e.prototype.ngDoCheck=function(){this.updateLayers()},e.prototype.updateLayers=function(){var e=this.leafletDirective.getMap(),t=this.controlLayers.getLayersControl();if(null!=e&&null!=t){ | ||
_this.controlLayers.init({},_this.layersControlOptions).addTo(_this.leafletDirective.getMap())});this.updateLayers()};LeafletLayersControlDirective.prototype.ngOnDestroy=function(){this.layersControlConfig={baseLayers:{},overlays:{}};this.controlLayers.getLayersControl().remove()};LeafletLayersControlDirective.prototype.ngDoCheck=function(){this.updateLayers()};LeafletLayersControlDirective.prototype.updateLayers=function(){var map=this.leafletDirective.getMap();var layersControl=this.controlLayers.getLayersControl();if(null!=map&&null!=layersControl){ | ||
// Run the baselayers differ | ||
if(null!=this.baseLayersDiffer&&null!=this.layersControlConfigValue.baseLayers){var n=this.baseLayersDiffer.diff(this.layersControlConfigValue.baseLayers);this.controlLayers.applyBaseLayerChanges(n)} | ||
if(null!=this.baseLayersDiffer&&null!=this.layersControlConfigValue.baseLayers){var changes=this.baseLayersDiffer.diff(this.layersControlConfigValue.baseLayers);this.controlLayers.applyBaseLayerChanges(changes)} | ||
// Run the overlays differ | ||
if(null!=this.overlaysDiffer&&null!=this.layersControlConfigValue.overlays){n=this.overlaysDiffer.diff(this.layersControlConfigValue.overlays);this.controlLayers.applyOverlayChanges(n)}}},e.decorators=[{type:o.Directive,args:[{selector:"[leafletLayersControl]"}]}], | ||
/** @nocollapse */ | ||
e.ctorParameters=function(){return[{type:t},{type:o.KeyValueDiffers},{type:o.NgZone}]},e.propDecorators={layersControlConfig:[{type:o.Input,args:["leafletLayersControl"]}],layersControlOptions:[{type:o.Input,args:["leafletLayersControlOptions"]}],layersControlReady:[{type:o.Output,args:["leafletLayersControlReady"]}]},e}(),f=/** @class */function(){function e(e,t,n){this.differs=t,this.zone=n, | ||
if(null!=this.overlaysDiffer&&null!=this.layersControlConfigValue.overlays){var changes=this.overlaysDiffer.diff(this.layersControlConfigValue.overlays);this.controlLayers.applyOverlayChanges(changes)}}};LeafletLayersControlDirective.decorators=[{type:core.Directive,args:[{selector:"[leafletLayersControl]"}]}]; | ||
/** @nocollapse */LeafletLayersControlDirective.ctorParameters=function(){return[{type:LeafletDirective},{type:core.KeyValueDiffers},{type:core.NgZone}]};LeafletLayersControlDirective.propDecorators={layersControlConfig:[{type:core.Input,args:["leafletLayersControl"]}],layersControlOptions:[{type:core.Input,args:["leafletLayersControlOptions"]}],layersControlReady:[{type:core.Output,args:["leafletLayersControlReady"]}]};return LeafletLayersControlDirective}(); | ||
/** | ||
* Baselayers directive | ||
* | ||
* This directive is provided as a convenient way to add baselayers to the map. The input accepts | ||
* a key-value map of layer name -> layer. Mutable changed are detected. On changes, a differ is | ||
* used to determine what changed so that layers are appropriately added or removed. This directive | ||
* will also add the layers control so users can switch between available base layers. | ||
* | ||
* To specify which layer to show as the 'active' baselayer, you will want to add it to the map | ||
* using the layers directive. Otherwise, the plugin will use the last one it sees. | ||
*/var LeafletBaseLayersDirective=/** @class */function(){function LeafletBaseLayersDirective(leafletDirective,differs,zone){this.differs=differs;this.zone=zone; | ||
// Output for once the layers control is ready | ||
this.layersControlReady=new o.EventEmitter,this.leafletDirective=new s(e),this.controlLayers=new u(this.zone,this.layersControlReady),this.baseLayersDiffer=this.differs.find({}).create()}return Object.defineProperty(e.prototype,"baseLayers",{get:function(){return this.baseLayersValue},set: | ||
this.layersControlReady=new core.EventEmitter;this.leafletDirective=new LeafletDirectiveWrapper(leafletDirective);this.controlLayers=new LeafletControlLayersWrapper(this.zone,this.layersControlReady);this.baseLayersDiffer=this.differs.find({}).create()}Object.defineProperty(LeafletBaseLayersDirective.prototype,"baseLayers",{get:function(){return this.baseLayersValue}, | ||
// Set/get baseLayers | ||
function(e){this.baseLayersValue=e,this.updateBaseLayers()},enumerable:!0,configurable:!0}),e.prototype.ngOnDestroy=function(){this.baseLayers={},this.controlLayers.getLayersControl().remove()},e.prototype.ngOnInit=function(){var e=this; | ||
set:function(v){this.baseLayersValue=v;this.updateBaseLayers()},enumerable:true,configurable:true});LeafletBaseLayersDirective.prototype.ngOnDestroy=function(){this.baseLayers={};this.controlLayers.getLayersControl().remove()};LeafletBaseLayersDirective.prototype.ngOnInit=function(){var _this=this; | ||
// Init the map | ||
this.leafletDirective.init(), | ||
this.leafletDirective.init(); | ||
// Create the control outside angular to prevent events from triggering chnage detection | ||
this.zone.runOutsideAngular(function(){ | ||
// Initially configure the controlLayers | ||
// Initially configure the controlLayers | ||
e.controlLayers.init({},e.layersControlOptions).addTo(e.leafletDirective.getMap())}),this.updateBaseLayers()},e.prototype.ngDoCheck=function(){this.updateBaseLayers()},e.prototype.updateBaseLayers=function(){var e=this.leafletDirective.getMap(),t=this.controlLayers.getLayersControl();if(null!=e&&null!=t&&null!=this.baseLayersDiffer){var n=this.baseLayersDiffer.diff(this.baseLayersValue);this.controlLayers.applyBaseLayerChanges(n).changed()&&this.syncBaseLayer()}}, | ||
_this.controlLayers.init({},_this.layersControlOptions).addTo(_this.leafletDirective.getMap())});this.updateBaseLayers()};LeafletBaseLayersDirective.prototype.ngDoCheck=function(){this.updateBaseLayers()};LeafletBaseLayersDirective.prototype.updateBaseLayers=function(){var map=this.leafletDirective.getMap();var layersControl=this.controlLayers.getLayersControl();if(null!=map&&null!=layersControl&&null!=this.baseLayersDiffer){var changes=this.baseLayersDiffer.diff(this.baseLayersValue);var results=this.controlLayers.applyBaseLayerChanges(changes);if(results.changed()){this.syncBaseLayer()}}}; | ||
/** | ||
* Check the current base layer and change it to the new one if necessary | ||
*/ | ||
/** | ||
* Check the current base layer and change it to the new one if necessary | ||
*/ | ||
e.prototype.syncBaseLayer= | ||
/** | ||
* Check the current base layer and change it to the new one if necessary | ||
*/ | ||
function(){var e,t=this,n=this.leafletDirective.getMap(),o=r.mapToArray(this.baseLayers); | ||
*/LeafletBaseLayersDirective.prototype.syncBaseLayer=function(){var _this=this;var map=this.leafletDirective.getMap();var layers=LeafletUtil.mapToArray(this.baseLayers);var foundLayer; | ||
// Search all the layers in the map to see if we can find them in the baselayer array | ||
n.eachLayer(function(t){e=o.find(function(e){return t===e})}), | ||
map.eachLayer(function(l){foundLayer=layers.find(function(bl){return l===bl})}); | ||
// Did we find the layer? | ||
null!=e? | ||
if(null!=foundLayer){ | ||
// Yes - set the baselayer to the one we found | ||
this.baseLayer=e: | ||
this.baseLayer=foundLayer}else{ | ||
// No - set the baselayer to the first in the array and add it to the map | ||
0<o.length&&(this.baseLayer=o[0], | ||
if(layers.length>0){this.baseLayer=layers[0]; | ||
// Add layers outside of angular to prevent events from triggering change detection | ||
this.zone.runOutsideAngular(function(){t.baseLayer.addTo(n)}))},e.decorators=[{type:o.Directive,args:[{selector:"[leafletBaseLayers]"}]}], | ||
/** @nocollapse */ | ||
e.ctorParameters=function(){return[{type:t},{type:o.KeyValueDiffers},{type:o.NgZone}]},e.propDecorators={baseLayers:[{type:o.Input,args:["leafletBaseLayers"]}],layersControlOptions:[{type:o.Input,args:["leafletLayersControlOptions"]}],layersControlReady:[{type:o.Output,args:["leafletLayersControlReady"]}]},e}(),h=/** @class */function(){function e(){}return e.forRoot=function(){return{ngModule:e,providers:[]}},e.decorators=[{type:o.NgModule,args:[{exports:[t,n,i,y,f],declarations:[t,n,i,y,f]}]}],e}(),c=/** @class */function(){function o(e,t,n){this.type=e,this.url=t,this.options=n} | ||
this.zone.runOutsideAngular(function(){_this.baseLayer.addTo(map)})}}};LeafletBaseLayersDirective.decorators=[{type:core.Directive,args:[{selector:"[leafletBaseLayers]"}]}]; | ||
/** @nocollapse */LeafletBaseLayersDirective.ctorParameters=function(){return[{type:LeafletDirective},{type:core.KeyValueDiffers},{type:core.NgZone}]};LeafletBaseLayersDirective.propDecorators={baseLayers:[{type:core.Input,args:["leafletBaseLayers"]}],layersControlOptions:[{type:core.Input,args:["leafletLayersControlOptions"]}],layersControlReady:[{type:core.Output,args:["leafletLayersControlReady"]}]};return LeafletBaseLayersDirective}();var LeafletModule=/** @class */function(){function LeafletModule(){}LeafletModule.forRoot=function(){return{ngModule:LeafletModule,providers:[]}};LeafletModule.decorators=[{type:core.NgModule,args:[{exports:[LeafletDirective,LeafletLayerDirective,LeafletLayersDirective,LeafletLayersControlDirective,LeafletBaseLayersDirective],declarations:[LeafletDirective,LeafletLayerDirective,LeafletLayersDirective,LeafletLayersControlDirective,LeafletBaseLayersDirective]}]}];return LeafletModule}();var LeafletTileLayerDefinition=/** @class */function(){function LeafletTileLayerDefinition(type,url,options){this.type=type;this.url=url;this.options=options} | ||
/** | ||
* Creates a TileLayer from the provided definition. This is a convenience function | ||
* to help with generating layers from objects. | ||
* | ||
* @param layerDef The layer to create | ||
* @returns {TileLayer} The TileLayer that has been created | ||
*/ | ||
/** | ||
* Creates a TileLayer from the provided definition. This is a convenience function | ||
@@ -289,19 +206,4 @@ * to help with generating layers from objects. | ||
* @returns {TileLayer} The TileLayer that has been created | ||
*/return o.createTileLayer= | ||
*/LeafletTileLayerDefinition.createTileLayer=function(layerDef){var layer;switch(layerDef.type){case"xyz":layer=leaflet.tileLayer(layerDef.url,layerDef.options);break;case"wms":default:layer=leaflet.tileLayer.wms(layerDef.url,layerDef.options);break}return layer}; | ||
/** | ||
* Creates a TileLayer from the provided definition. This is a convenience function | ||
* to help with generating layers from objects. | ||
* | ||
* @param layerDef The layer to create | ||
* @returns {TileLayer} The TileLayer that has been created | ||
*/ | ||
function(e){var t;switch(e.type){case"xyz":t=a.tileLayer(e.url,e.options);break;case"wms":default:t=a.tileLayer.wms(e.url,e.options)}return t}, | ||
/** | ||
* Creates a TileLayer for each key in the incoming map. This is a convenience function | ||
* for generating an associative array of layers from an associative array of objects | ||
* | ||
* @param layerDefs A map of key to tile layer definition | ||
* @returns {{[p: string]: TileLayer}} A new map of key to TileLayer | ||
*/ | ||
/** | ||
* Creates a TileLayer for each key in the incoming map. This is a convenience function | ||
@@ -312,29 +214,8 @@ * for generating an associative array of layers from an associative array of objects | ||
* @returns {{[p: string]: TileLayer}} A new map of key to TileLayer | ||
*/ | ||
o.createTileLayers= | ||
*/LeafletTileLayerDefinition.createTileLayers=function(layerDefs){var layers={};for(var k in layerDefs){if(layerDefs.hasOwnProperty(k)){layers[k]=LeafletTileLayerDefinition.createTileLayer(layerDefs[k])}}return layers}; | ||
/** | ||
* Creates a TileLayer for each key in the incoming map. This is a convenience function | ||
* for generating an associative array of layers from an associative array of objects | ||
* | ||
* @param layerDefs A map of key to tile layer definition | ||
* @returns {{[p: string]: TileLayer}} A new map of key to TileLayer | ||
*/ | ||
function(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=o.createTileLayer(e[n]));return t}, | ||
/** | ||
* Create a Tile Layer from the current state of this object | ||
* | ||
* @returns {TileLayer} A new TileLayer | ||
*/ | ||
/** | ||
* Create a Tile Layer from the current state of this object | ||
* | ||
* @returns {TileLayer} A new TileLayer | ||
*/ | ||
o.prototype.createTileLayer= | ||
/** | ||
* Create a Tile Layer from the current state of this object | ||
* | ||
* @returns {TileLayer} A new TileLayer | ||
*/ | ||
function(){return o.createTileLayer(this)},o}();e.LeafletModule=h,e.LeafletDirective=t,e.LeafletDirectiveWrapper=s,e.LeafletTileLayerDefinition=c,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
*/LeafletTileLayerDefinition.prototype.createTileLayer=function(){return LeafletTileLayerDefinition.createTileLayer(this)};return LeafletTileLayerDefinition}();exports.LeafletModule=LeafletModule;exports.LeafletDirective=LeafletDirective;exports.LeafletDirectiveWrapper=LeafletDirectiveWrapper;exports.LeafletTileLayerDefinition=LeafletTileLayerDefinition;Object.defineProperty(exports,"__esModule",{value:true})}); | ||
//# sourceMappingURL=ngx-leaflet.js.map |
@@ -6,3 +6,2 @@ import { Directive, ElementRef, EventEmitter, HostListener, Input, NgZone, Output } from '@angular/core'; | ||
function LeafletDirective(element, zone) { | ||
// Nothing here | ||
this.element = element; | ||
@@ -38,2 +37,3 @@ this.zone = zone; | ||
this.onMapZoomEnd = new EventEmitter(); | ||
// Nothing here | ||
} | ||
@@ -45,3 +45,2 @@ LeafletDirective.prototype.ngOnInit = function () { | ||
// Create the map with some reasonable defaults | ||
// Create the map with some reasonable defaults | ||
_this.map = map(_this.element.nativeElement, _this.options); | ||
@@ -73,9 +72,9 @@ _this.addMapEventListeners(); | ||
/* | ||
* The following code is to address an issue with our (basic) implementation of | ||
* zooming and panning. From our testing, it seems that a pan operation followed | ||
* by a zoom operation in the same thread will interfere with eachother. The zoom | ||
* operation interrupts/cancels the pan, resulting in a final center point that is | ||
* inaccurate. The solution seems to be to either separate them with a timeout or | ||
* to collapse them into a setView call. | ||
*/ | ||
* The following code is to address an issue with our (basic) implementation of | ||
* zooming and panning. From our testing, it seems that a pan operation followed | ||
* by a zoom operation in the same thread will interfere with eachother. The zoom | ||
* operation interrupts/cancels the pan, resulting in a final center point that is | ||
* inaccurate. The solution seems to be to either separate them with a timeout or | ||
* to collapse them into a setView call. | ||
*/ | ||
// Zooming and Panning | ||
@@ -146,9 +145,3 @@ if (changes['zoom'] && changes['center'] && null != this.zoom && null != this.center) { | ||
*/ | ||
/** | ||
* Resize the map to fit it's parent container | ||
*/ | ||
LeafletDirective.prototype.doResize = /** | ||
* Resize the map to fit it's parent container | ||
*/ | ||
function () { | ||
LeafletDirective.prototype.doResize = function () { | ||
var _this = this; | ||
@@ -158,3 +151,2 @@ // Run this outside of angular so the map events stay outside of angular | ||
// Invalidate the map size to trigger it to update itself | ||
// Invalidate the map size to trigger it to update itself | ||
_this.map.invalidateSize({}); | ||
@@ -166,9 +158,3 @@ }); | ||
*/ | ||
/** | ||
* Manage a delayed resize of the component | ||
*/ | ||
LeafletDirective.prototype.delayResize = /** | ||
* Manage a delayed resize of the component | ||
*/ | ||
function () { | ||
LeafletDirective.prototype.delayResize = function () { | ||
if (null != this.resizeTimer) { | ||
@@ -184,13 +170,3 @@ clearTimeout(this.resizeTimer); | ||
*/ | ||
/** | ||
* Set the view (center/zoom) all at once | ||
* @param center The new center | ||
* @param zoom The new zoom level | ||
*/ | ||
LeafletDirective.prototype.setView = /** | ||
* Set the view (center/zoom) all at once | ||
* @param center The new center | ||
* @param zoom The new zoom level | ||
*/ | ||
function (center, zoom) { | ||
LeafletDirective.prototype.setView = function (center, zoom) { | ||
if (this.map && null != center && null != zoom) { | ||
@@ -204,11 +180,3 @@ this.map.setView(center, zoom, this.zoomPanOptions); | ||
*/ | ||
/** | ||
* Set the map zoom level | ||
* @param zoom the new zoom level for the map | ||
*/ | ||
LeafletDirective.prototype.setZoom = /** | ||
* Set the map zoom level | ||
* @param zoom the new zoom level for the map | ||
*/ | ||
function (zoom) { | ||
LeafletDirective.prototype.setZoom = function (zoom) { | ||
if (this.map && null != zoom) { | ||
@@ -222,11 +190,3 @@ this.map.setZoom(zoom, this.zoomOptions); | ||
*/ | ||
/** | ||
* Set the center of the map | ||
* @param center the center point | ||
*/ | ||
LeafletDirective.prototype.setCenter = /** | ||
* Set the center of the map | ||
* @param center the center point | ||
*/ | ||
function (center) { | ||
LeafletDirective.prototype.setCenter = function (center) { | ||
if (this.map && null != center) { | ||
@@ -240,11 +200,3 @@ this.map.panTo(center, this.panOptions); | ||
*/ | ||
/** | ||
* Fit the map to the bounds | ||
* @param latLngBounds the boundary to set | ||
*/ | ||
LeafletDirective.prototype.setFitBounds = /** | ||
* Fit the map to the bounds | ||
* @param latLngBounds the boundary to set | ||
*/ | ||
function (latLngBounds) { | ||
LeafletDirective.prototype.setFitBounds = function (latLngBounds) { | ||
if (this.map && null != latLngBounds) { | ||
@@ -258,11 +210,3 @@ this.map.fitBounds(latLngBounds, this.fitBoundsOptions); | ||
*/ | ||
/** | ||
* Set the map's max bounds | ||
* @param latLngBounds the boundary to set | ||
*/ | ||
LeafletDirective.prototype.setMaxBounds = /** | ||
* Set the map's max bounds | ||
* @param latLngBounds the boundary to set | ||
*/ | ||
function (latLngBounds) { | ||
LeafletDirective.prototype.setMaxBounds = function (latLngBounds) { | ||
if (this.map && null != latLngBounds) { | ||
@@ -276,11 +220,3 @@ this.map.setMaxBounds(latLngBounds); | ||
*/ | ||
/** | ||
* Set the map's min zoom | ||
* @param number the new min zoom | ||
*/ | ||
LeafletDirective.prototype.setMinZoom = /** | ||
* Set the map's min zoom | ||
* @param number the new min zoom | ||
*/ | ||
function (zoom) { | ||
LeafletDirective.prototype.setMinZoom = function (zoom) { | ||
if (this.map && null != zoom) { | ||
@@ -294,11 +230,3 @@ this.map.setMinZoom(zoom); | ||
*/ | ||
/** | ||
* Set the map's min zoom | ||
* @param number the new min zoom | ||
*/ | ||
LeafletDirective.prototype.setMaxZoom = /** | ||
* Set the map's min zoom | ||
* @param number the new min zoom | ||
*/ | ||
function (zoom) { | ||
LeafletDirective.prototype.setMaxZoom = function (zoom) { | ||
if (this.map && null != zoom) { | ||
@@ -315,33 +243,33 @@ this.map.setMaxZoom(zoom); | ||
LeafletDirective.ctorParameters = function () { return [ | ||
{ type: ElementRef, }, | ||
{ type: NgZone, }, | ||
{ type: ElementRef }, | ||
{ type: NgZone } | ||
]; }; | ||
LeafletDirective.propDecorators = { | ||
"fitBoundsOptions": [{ type: Input, args: ['leafletFitBoundsOptions',] },], | ||
"panOptions": [{ type: Input, args: ['leafletPanOptions',] },], | ||
"zoomOptions": [{ type: Input, args: ['leafletZoomOptions',] },], | ||
"zoomPanOptions": [{ type: Input, args: ['leafletZoomPanOptions',] },], | ||
"options": [{ type: Input, args: ['leafletOptions',] },], | ||
"mapReady": [{ type: Output, args: ['leafletMapReady',] },], | ||
"zoom": [{ type: Input, args: ['leafletZoom',] },], | ||
"zoomChange": [{ type: Output, args: ['leafletZoomChange',] },], | ||
"center": [{ type: Input, args: ['leafletCenter',] },], | ||
"centerChange": [{ type: Output, args: ['leafletCenterChange',] },], | ||
"fitBounds": [{ type: Input, args: ['leafletFitBounds',] },], | ||
"maxBounds": [{ type: Input, args: ['leafletMaxBounds',] },], | ||
"minZoom": [{ type: Input, args: ['leafletMinZoom',] },], | ||
"maxZoom": [{ type: Input, args: ['leafletMaxZoom',] },], | ||
"onClick": [{ type: Output, args: ['leafletClick',] },], | ||
"onDoubleClick": [{ type: Output, args: ['leafletDoubleClick',] },], | ||
"onMouseDown": [{ type: Output, args: ['leafletMouseDown',] },], | ||
"onMouseUp": [{ type: Output, args: ['leafletMouseUp',] },], | ||
"onMouseMove": [{ type: Output, args: ['leafletMouseMove',] },], | ||
"onMouseOver": [{ type: Output, args: ['leafletMouseOver',] },], | ||
"onMapMove": [{ type: Output, args: ['leafletMapMove',] },], | ||
"onMapMoveStart": [{ type: Output, args: ['leafletMapMoveStart',] },], | ||
"onMapMoveEnd": [{ type: Output, args: ['leafletMapMoveEnd',] },], | ||
"onMapZoom": [{ type: Output, args: ['leafletMapZoom',] },], | ||
"onMapZoomStart": [{ type: Output, args: ['leafletMapZoomStart',] },], | ||
"onMapZoomEnd": [{ type: Output, args: ['leafletMapZoomEnd',] },], | ||
"onResize": [{ type: HostListener, args: ['window:resize', [],] },], | ||
fitBoundsOptions: [{ type: Input, args: ['leafletFitBoundsOptions',] }], | ||
panOptions: [{ type: Input, args: ['leafletPanOptions',] }], | ||
zoomOptions: [{ type: Input, args: ['leafletZoomOptions',] }], | ||
zoomPanOptions: [{ type: Input, args: ['leafletZoomPanOptions',] }], | ||
options: [{ type: Input, args: ['leafletOptions',] }], | ||
mapReady: [{ type: Output, args: ['leafletMapReady',] }], | ||
zoom: [{ type: Input, args: ['leafletZoom',] }], | ||
zoomChange: [{ type: Output, args: ['leafletZoomChange',] }], | ||
center: [{ type: Input, args: ['leafletCenter',] }], | ||
centerChange: [{ type: Output, args: ['leafletCenterChange',] }], | ||
fitBounds: [{ type: Input, args: ['leafletFitBounds',] }], | ||
maxBounds: [{ type: Input, args: ['leafletMaxBounds',] }], | ||
minZoom: [{ type: Input, args: ['leafletMinZoom',] }], | ||
maxZoom: [{ type: Input, args: ['leafletMaxZoom',] }], | ||
onClick: [{ type: Output, args: ['leafletClick',] }], | ||
onDoubleClick: [{ type: Output, args: ['leafletDoubleClick',] }], | ||
onMouseDown: [{ type: Output, args: ['leafletMouseDown',] }], | ||
onMouseUp: [{ type: Output, args: ['leafletMouseUp',] }], | ||
onMouseMove: [{ type: Output, args: ['leafletMouseMove',] }], | ||
onMouseOver: [{ type: Output, args: ['leafletMouseOver',] }], | ||
onMapMove: [{ type: Output, args: ['leafletMapMove',] }], | ||
onMapMoveStart: [{ type: Output, args: ['leafletMapMoveStart',] }], | ||
onMapMoveEnd: [{ type: Output, args: ['leafletMapMoveEnd',] }], | ||
onMapZoom: [{ type: Output, args: ['leafletMapZoom',] }], | ||
onMapZoomStart: [{ type: Output, args: ['leafletMapZoomStart',] }], | ||
onMapZoomEnd: [{ type: Output, args: ['leafletMapZoomEnd',] }], | ||
onResize: [{ type: HostListener, args: ['window:resize', [],] }] | ||
}; | ||
@@ -348,0 +276,0 @@ return LeafletDirective; |
@@ -32,5 +32,4 @@ import { Directive, EventEmitter, Input, KeyValueDiffers, NgZone, Output } from '@angular/core'; | ||
}, | ||
set: | ||
// Set/get baseLayers | ||
function (v) { | ||
set: function (v) { | ||
this.baseLayersValue = v; | ||
@@ -53,3 +52,2 @@ this.updateBaseLayers(); | ||
// Initially configure the controlLayers | ||
// Initially configure the controlLayers | ||
_this.controlLayers | ||
@@ -78,9 +76,3 @@ .init({}, _this.layersControlOptions) | ||
*/ | ||
/** | ||
* Check the current base layer and change it to the new one if necessary | ||
*/ | ||
LeafletBaseLayersDirective.prototype.syncBaseLayer = /** | ||
* Check the current base layer and change it to the new one if necessary | ||
*/ | ||
function () { | ||
LeafletBaseLayersDirective.prototype.syncBaseLayer = function () { | ||
var _this = this; | ||
@@ -117,10 +109,10 @@ var map = this.leafletDirective.getMap(); | ||
LeafletBaseLayersDirective.ctorParameters = function () { return [ | ||
{ type: LeafletDirective, }, | ||
{ type: KeyValueDiffers, }, | ||
{ type: NgZone, }, | ||
{ type: LeafletDirective }, | ||
{ type: KeyValueDiffers }, | ||
{ type: NgZone } | ||
]; }; | ||
LeafletBaseLayersDirective.propDecorators = { | ||
"baseLayers": [{ type: Input, args: ['leafletBaseLayers',] },], | ||
"layersControlOptions": [{ type: Input, args: ['leafletLayersControlOptions',] },], | ||
"layersControlReady": [{ type: Output, args: ['leafletLayersControlReady',] },], | ||
baseLayers: [{ type: Input, args: ['leafletBaseLayers',] }], | ||
layersControlOptions: [{ type: Input, args: ['leafletLayersControlOptions',] }], | ||
layersControlReady: [{ type: Output, args: ['leafletLayersControlReady',] }] | ||
}; | ||
@@ -127,0 +119,0 @@ return LeafletBaseLayersDirective; |
@@ -57,3 +57,2 @@ import { Directive, EventEmitter, Input, KeyValueDiffers, NgZone, Output } from '@angular/core'; | ||
// Set up all the initial settings | ||
// Set up all the initial settings | ||
_this.controlLayers | ||
@@ -95,10 +94,10 @@ .init({}, _this.layersControlOptions) | ||
LeafletLayersControlDirective.ctorParameters = function () { return [ | ||
{ type: LeafletDirective, }, | ||
{ type: KeyValueDiffers, }, | ||
{ type: NgZone, }, | ||
{ type: LeafletDirective }, | ||
{ type: KeyValueDiffers }, | ||
{ type: NgZone } | ||
]; }; | ||
LeafletLayersControlDirective.propDecorators = { | ||
"layersControlConfig": [{ type: Input, args: ['leafletLayersControl',] },], | ||
"layersControlOptions": [{ type: Input, args: ['leafletLayersControlOptions',] },], | ||
"layersControlReady": [{ type: Output, args: ['leafletLayersControlReady',] },], | ||
layersControlConfig: [{ type: Input, args: ['leafletLayersControl',] }], | ||
layersControlOptions: [{ type: Input, args: ['leafletLayersControlOptions',] }], | ||
layersControlReady: [{ type: Output, args: ['leafletLayersControlReady',] }] | ||
}; | ||
@@ -105,0 +104,0 @@ return LeafletLayersControlDirective; |
@@ -57,9 +57,9 @@ import { Directive, EventEmitter, Input, NgZone, Output } from '@angular/core'; | ||
LeafletLayerDirective.ctorParameters = function () { return [ | ||
{ type: LeafletDirective, }, | ||
{ type: NgZone, }, | ||
{ type: LeafletDirective }, | ||
{ type: NgZone } | ||
]; }; | ||
LeafletLayerDirective.propDecorators = { | ||
"layer": [{ type: Input, args: ['leafletLayer',] },], | ||
"onAdd": [{ type: Output, args: ['leafletLayerAdd',] },], | ||
"onRemove": [{ type: Output, args: ['leafletLayerRemove',] },], | ||
layer: [{ type: Input, args: ['leafletLayer',] }], | ||
onAdd: [{ type: Output, args: ['leafletLayerAdd',] }], | ||
onRemove: [{ type: Output, args: ['leafletLayerRemove',] }] | ||
}; | ||
@@ -66,0 +66,0 @@ return LeafletLayerDirective; |
@@ -30,5 +30,4 @@ import { Directive, Input, IterableDiffers, NgZone } from '@angular/core'; | ||
}, | ||
set: | ||
// Set/get the layers | ||
function (v) { | ||
set: function (v) { | ||
this.layersValue = v; | ||
@@ -59,15 +58,3 @@ // Now that we have a differ, do an immediate layer update | ||
*/ | ||
/** | ||
* Update the state of the layers. | ||
* We use an iterable differ to synchronize the map layers with the state of the bound layers array. | ||
* This is important because it allows us to react to changes to the contents of the array as well | ||
* as changes to the actual array instance. | ||
*/ | ||
LeafletLayersDirective.prototype.updateLayers = /** | ||
* Update the state of the layers. | ||
* We use an iterable differ to synchronize the map layers with the state of the bound layers array. | ||
* This is important because it allows us to react to changes to the contents of the array as well | ||
* as changes to the actual array instance. | ||
*/ | ||
function () { | ||
LeafletLayersDirective.prototype.updateLayers = function () { | ||
var map = this.leafletDirective.getMap(); | ||
@@ -96,8 +83,8 @@ if (null != map && null != this.layersDiffer) { | ||
LeafletLayersDirective.ctorParameters = function () { return [ | ||
{ type: LeafletDirective, }, | ||
{ type: IterableDiffers, }, | ||
{ type: NgZone, }, | ||
{ type: LeafletDirective }, | ||
{ type: IterableDiffers }, | ||
{ type: NgZone } | ||
]; }; | ||
LeafletLayersDirective.propDecorators = { | ||
"layers": [{ type: Input, args: ['leafletLayers',] },], | ||
layers: [{ type: Input, args: ['leafletLayers',] }] | ||
}; | ||
@@ -104,0 +91,0 @@ return LeafletLayersDirective; |
@@ -15,17 +15,3 @@ import { tileLayer } from 'leaflet'; | ||
*/ | ||
/** | ||
* Creates a TileLayer from the provided definition. This is a convenience function | ||
* to help with generating layers from objects. | ||
* | ||
* @param layerDef The layer to create | ||
* @returns {TileLayer} The TileLayer that has been created | ||
*/ | ||
LeafletTileLayerDefinition.createTileLayer = /** | ||
* Creates a TileLayer from the provided definition. This is a convenience function | ||
* to help with generating layers from objects. | ||
* | ||
* @param layerDef The layer to create | ||
* @returns {TileLayer} The TileLayer that has been created | ||
*/ | ||
function (layerDef) { | ||
LeafletTileLayerDefinition.createTileLayer = function (layerDef) { | ||
var layer; | ||
@@ -50,17 +36,3 @@ switch (layerDef.type) { | ||
*/ | ||
/** | ||
* Creates a TileLayer for each key in the incoming map. This is a convenience function | ||
* for generating an associative array of layers from an associative array of objects | ||
* | ||
* @param layerDefs A map of key to tile layer definition | ||
* @returns {{[p: string]: TileLayer}} A new map of key to TileLayer | ||
*/ | ||
LeafletTileLayerDefinition.createTileLayers = /** | ||
* Creates a TileLayer for each key in the incoming map. This is a convenience function | ||
* for generating an associative array of layers from an associative array of objects | ||
* | ||
* @param layerDefs A map of key to tile layer definition | ||
* @returns {{[p: string]: TileLayer}} A new map of key to TileLayer | ||
*/ | ||
function (layerDefs) { | ||
LeafletTileLayerDefinition.createTileLayers = function (layerDefs) { | ||
var layers = {}; | ||
@@ -79,13 +51,3 @@ for (var k in layerDefs) { | ||
*/ | ||
/** | ||
* Create a Tile Layer from the current state of this object | ||
* | ||
* @returns {TileLayer} A new TileLayer | ||
*/ | ||
LeafletTileLayerDefinition.prototype.createTileLayer = /** | ||
* Create a Tile Layer from the current state of this object | ||
* | ||
* @returns {TileLayer} A new TileLayer | ||
*/ | ||
function () { | ||
LeafletTileLayerDefinition.prototype.createTileLayer = function () { | ||
return LeafletTileLayerDefinition.createTileLayer(this); | ||
@@ -92,0 +54,0 @@ }; |
@@ -6,3 +6,3 @@ { | ||
"description": "Angular.io components for Leaflet", | ||
"version": "3.1.0", | ||
"version": "4.0.0", | ||
"author": "Asymmetrik, Ltd.", | ||
@@ -23,9 +23,18 @@ "copyright": "Copyright Asymmetrik, Ltd. 2007-2018 - All Rights Reserved.", | ||
"scripts": { | ||
"demo": "gulp dev", | ||
"build": "gulp build" | ||
"build": "npm run compile && npm run bundle", | ||
"prebuild": "npm run lint", | ||
"demo": "(webpack-dev-server & npm run watch)", | ||
"predemo": "npm run lint", | ||
"bundle": "npm run rollup && npm run uglify", | ||
"compile": "ngc -p tsconfig-aot.json", | ||
"lint": "tslint -c tslint.json -t stylish 'src/**/*.ts'", | ||
"rollup": "rollup -c rollup.config.js", | ||
"uglify": "uglifyjs --comments 'license' -o ./dist/bundles/ngx-leaflet.min.js -- ./dist/bundles/ngx-leaflet.js", | ||
"watch": " watch 'npm run lint' ./src" | ||
}, | ||
"peerDependencies": { | ||
"@angular/core": ">=5", | ||
"@angular/common": ">=5", | ||
"@angular/core": ">=6", | ||
"@angular/common": ">=6", | ||
@@ -36,11 +45,11 @@ "leaflet": "1" | ||
"devDependencies": { | ||
"@angular/common": "5", | ||
"@angular/compiler": "5", | ||
"@angular/compiler-cli": "5", | ||
"@angular/core": "5", | ||
"@angular/forms": "5", | ||
"@angular/platform-browser": "5", | ||
"@angular/platform-browser-dynamic": "5", | ||
"@angular/common": "6", | ||
"@angular/compiler": "6", | ||
"@angular/compiler-cli": "6", | ||
"@angular/core": "6", | ||
"@angular/forms": "6", | ||
"@angular/platform-browser": "6", | ||
"@angular/platform-browser-dynamic": "6", | ||
"bootstrap": "4.0.0-beta.3", | ||
"bootstrap": "4", | ||
@@ -51,43 +60,30 @@ "leaflet": "1", | ||
"core-js": "2.5", | ||
"rxjs": "5.5", | ||
"rxjs": "6", | ||
"zone.js": "0.8", | ||
"@types/node": "8", | ||
"@types/node": "10", | ||
"merge2": "1.2", | ||
"rollup": "0.54", | ||
"typescript": "2.7", | ||
"tslint": "5", | ||
"typescript": "2.6", | ||
"tslint": "5.9", | ||
"tslint-stylish": "2.1", | ||
"rollup": "0.62", | ||
"uglify-js": "3", | ||
"webpack": "3.10", | ||
"webpack-dev-server": "2.11", | ||
"webpack-stats-plugin": "0.1", | ||
"webpack": "4", | ||
"webpack-cli": "3", | ||
"webpack-dev-server": "3", | ||
"angular2-template-loader": "0.6", | ||
"awesome-typescript-loader": "3.4", | ||
"awesome-typescript-loader": "5", | ||
"css-loader": "0.28", | ||
"file-loader": "1.1", | ||
"html-loader": "0.5", | ||
"resolve-url-loader": "2.2", | ||
"sass-loader": "6.0", | ||
"node-sass": "4", | ||
"resolve-url-loader": "2", | ||
"sass-loader": "7", | ||
"source-map-loader": "0.2", | ||
"style-loader": "0.19", | ||
"url-loader": "0.6", | ||
"style-loader": "0.21", | ||
"url-loader": "1", | ||
"watch": "1" | ||
"gulp": "3.9", | ||
"gulp-filter": "5.1", | ||
"gulp-insert": "0.5", | ||
"gulp-load-plugins": "1.5", | ||
"gulp-rename": "1.2", | ||
"gulp-sourcemaps": "2.6", | ||
"gulp-typescript": "3.2", | ||
"gulp-tslint": "8.1", | ||
"gulp-uglify": "3.0", | ||
"gulp-util": "3.0", | ||
"run-sequence": "2.2", | ||
"through2": "2.0", | ||
"node-sass": "4.7" | ||
} | ||
} |
@@ -10,3 +10,3 @@ # @asymmetrik/ngx-leaflet | ||
> Provides flexible and extensible components for integrating Leaflet v0.7.x and v1.x into Angular.io projects. | ||
> Supports Angular v5, Ahead-of-Time compilation (AOT), and use in Angular-CLI based projects. | ||
> Supports Angular v6, Ahead-of-Time compilation (AOT), and use in Angular-CLI based projects. | ||
@@ -25,7 +25,8 @@ ## Table of Contents | ||
## Install | ||
Install the package and its peer dependencies via npm (or yarn): | ||
Install the package and its peer dependencies via yarn (or npm): | ||
``` | ||
npm install leaflet | ||
npm install @asymmetrik/ngx-leaflet | ||
yarn add leaflet | ||
yarn add @asymmetrik/ngx-leaflet | ||
``` | ||
@@ -35,6 +36,6 @@ | ||
``` | ||
npm install --save-dev @types/leaflet | ||
yarn add --save-dev @types/leaflet | ||
``` | ||
If you want to run the demo, clone the repository, perform an ```npm install```, ```npm run demo``` and then go to http://localhost:9000/src/demo/index.html | ||
If you want to run the demo, clone the repository, perform an ```yarn install```, ```npm run demo``` and then go to http://localhost:9000/src/demo/index.html | ||
@@ -635,3 +636,2 @@ | ||
### A Note About Markers | ||
@@ -726,2 +726,11 @@ If you use this component in an Angular.io project and your project uses a bundler like Webpack, you might run into issues using Markers on maps. | ||
### 4.0 | ||
Support for Angular 6. | ||
Also migrated to using npm scripts for the build (no more dev dependency on gulp). | ||
### 3.0 | ||
Support for Angular 5. Also cleaned up some of the functionality related to Angular zone management. | ||
Added documentation to README on Zone management. | ||
#### 3.1.0 | ||
@@ -732,5 +741,2 @@ Added [map events](#map-events), [layer events](#layer-events). | ||
### 3.0 | ||
Support for Angular 5. Also cleaned up some of the functionality related to Angular zone management. | ||
Added documentation to README on Zone management. | ||
@@ -751,2 +757,3 @@ ### 2.0 | ||
## Contribute | ||
@@ -753,0 +760,0 @@ PRs accepted. If you are part of Asymmetrik, please make contributions on feature branches off of the ```develop``` branch. If you are outside of Asymmetrik, please fork our repo to make contributions. |
@@ -5,16 +5,4 @@ | ||
* | ||
* This entry point is used by Webpack to place vendor code into it's own bundle during the build. This has the | ||
* benefit of separating application code from vendor code, allowing better caching for code that changes less | ||
* often and allowing parallel downloading of the two primary code bundles for the application. Follow the | ||
* commented organization pattern for adding new dependencies. | ||
* This file is used to organize all application-level global imports | ||
* | ||
* Polyfills - Should only be imported in this file, not directly by the application | ||
* | ||
* Global Imports - Dependencies that are not polyfills, but are not directly imported elsewhere in the app | ||
* | ||
* Angular Imports - All @angular dependencies | ||
* | ||
* Angular Third-Party - All angular-specific third-party dependencies | ||
* | ||
* Other Dependencies - All other third-party dependencies | ||
*/ | ||
@@ -29,6 +17,4 @@ | ||
import 'bootstrap/dist/css/bootstrap.css'; | ||
import 'leaflet/dist/leaflet.css'; | ||
// This addresses a weird thing with how Leaflet handles icon URLs. See README for details. | ||
@@ -39,16 +25,3 @@ import 'leaflet/dist/images/marker-shadow.png'; | ||
// Angular Imports | ||
import '@angular/common'; | ||
import '@angular/core'; | ||
import '@angular/forms'; | ||
import '@angular/platform-browser'; | ||
import '@angular/platform-browser-dynamic'; | ||
// Angular Third-Party | ||
// Other Dependencies | ||
import 'rxjs'; | ||
import 'zone.js'; | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
33
1
762
0
505969
106
3668