2
2
3
3
exports . __esModule = true ;
4
4
5
+ var _class , _temp ;
6
+
5
7
var _react = require ( 'react' ) ;
6
8
7
9
var _react2 = _interopRequireDefault ( _react ) ;
@@ -81,7 +83,7 @@ function shouldIgnoreLocation(loc) {
81
83
return isInvalid ( loc . lng ) || isInvalid ( loc . lat ) ;
82
84
}
83
85
84
- var HeatmapLayer = function ( _MapLayer ) {
86
+ exports . default = ( 0 , _reactLeaflet . withLeaflet ) ( ( _temp = _class = function ( _MapLayer ) {
85
87
_inherits ( HeatmapLayer , _MapLayer ) ;
86
88
87
89
function HeatmapLayer ( ) {
@@ -97,9 +99,9 @@ var HeatmapLayer = function (_MapLayer) {
97
99
HeatmapLayer . prototype . componentDidMount = function componentDidMount ( ) {
98
100
var _this2 = this ;
99
101
100
- var canAnimate = this . context . map . options . zoomAnimation && _leaflet2 . default . Browser . any3d ;
102
+ var canAnimate = this . props . leaflet . map . options . zoomAnimation && _leaflet2 . default . Browser . any3d ;
101
103
var zoomClass = 'leaflet-zoom-' + ( canAnimate ? 'animated' : 'hide' ) ;
102
- var mapSize = this . context . map . getSize ( ) ;
104
+ var mapSize = this . props . leaflet . map . getSize ( ) ;
103
105
var transformProp = _leaflet2 . default . DomUtil . testProp ( [ 'transformOrigin' , 'WebkitTransformOrigin' , 'msTransformOrigin' ] ) ;
104
106
105
107
this . _el = _leaflet2 . default . DomUtil . create ( 'canvas' , zoomClass ) ;
@@ -228,7 +230,7 @@ var HeatmapLayer = function (_MapLayer) {
228
230
} ;
229
231
230
232
HeatmapLayer . prototype . componentWillUnmount = function componentWillUnmount ( ) {
231
- safeRemoveLayer ( this . context . map , this . _el ) ;
233
+ safeRemoveLayer ( this . props . leaflet . map , this . _el ) ;
232
234
} ;
233
235
234
236
HeatmapLayer . prototype . fitBounds = function fitBounds ( ) {
@@ -242,11 +244,11 @@ var HeatmapLayer = function (_MapLayer) {
242
244
return ;
243
245
}
244
246
245
- this . context . map . fitBounds ( _leaflet2 . default . latLngBounds ( _leaflet2 . default . latLng ( sw ) , _leaflet2 . default . latLng ( ne ) ) ) ;
247
+ this . props . leaflet . map . fitBounds ( _leaflet2 . default . latLngBounds ( _leaflet2 . default . latLng ( sw ) , _leaflet2 . default . latLng ( ne ) ) ) ;
246
248
} ;
247
249
248
250
HeatmapLayer . prototype . componentDidUpdate = function componentDidUpdate ( ) {
249
- this . context . map . invalidateSize ( ) ;
251
+ this . props . leaflet . map . invalidateSize ( ) ;
250
252
if ( this . props . fitBoundsOnUpdate ) {
251
253
this . fitBounds ( ) ;
252
254
}
@@ -260,7 +262,7 @@ var HeatmapLayer = function (_MapLayer) {
260
262
HeatmapLayer . prototype . attachEvents = function attachEvents ( ) {
261
263
var _this3 = this ;
262
264
263
- var leafletMap = this . context . map ;
265
+ var leafletMap = this . props . leaflet . map ;
264
266
leafletMap . on ( 'viewreset' , function ( ) {
265
267
return _this3 . reset ( ) ;
266
268
} ) ;
@@ -273,8 +275,8 @@ var HeatmapLayer = function (_MapLayer) {
273
275
} ;
274
276
275
277
HeatmapLayer . prototype . _animateZoom = function _animateZoom ( e ) {
276
- var scale = this . context . map . getZoomScale ( e . zoom ) ;
277
- var offset = this . context . map . _getCenterOffset ( e . center ) . _multiplyBy ( - scale ) . subtract ( this . context . map . _getMapPanePos ( ) ) ;
278
+ var scale = this . props . leaflet . map . getZoomScale ( e . zoom ) ;
279
+ var offset = this . props . leaflet . map . _getCenterOffset ( e . center ) . _multiplyBy ( - scale ) . subtract ( this . props . leaflet . map . _getMapPanePos ( ) ) ;
278
280
279
281
if ( _leaflet2 . default . DomUtil . setTransform ) {
280
282
_leaflet2 . default . DomUtil . setTransform ( this . _el , offset , scale ) ;
@@ -284,10 +286,10 @@ var HeatmapLayer = function (_MapLayer) {
284
286
} ;
285
287
286
288
HeatmapLayer . prototype . reset = function reset ( ) {
287
- var topLeft = this . context . map . containerPointToLayerPoint ( [ 0 , 0 ] ) ;
289
+ var topLeft = this . props . leaflet . map . containerPointToLayerPoint ( [ 0 , 0 ] ) ;
288
290
_leaflet2 . default . DomUtil . setPosition ( this . _el , topLeft ) ;
289
291
290
- var size = this . context . map . getSize ( ) ;
292
+ var size = this . props . leaflet . map . getSize ( ) ;
291
293
292
294
if ( this . _heatmap . _width !== size . x ) {
293
295
this . _el . width = this . _heatmap . _width = size . x ;
@@ -296,7 +298,7 @@ var HeatmapLayer = function (_MapLayer) {
296
298
this . _el . height = this . _heatmap . _height = size . y ;
297
299
}
298
300
299
- if ( this . _heatmap && ! this . _frame && ! this . context . map . _animating ) {
301
+ if ( this . _heatmap && ! this . _frame && ! this . props . leaflet . map . _animating ) {
300
302
this . _frame = _leaflet2 . default . Util . requestAnimFrame ( this . redraw , this ) ;
301
303
}
302
304
@@ -305,16 +307,16 @@ var HeatmapLayer = function (_MapLayer) {
305
307
306
308
HeatmapLayer . prototype . redraw = function redraw ( ) {
307
309
var r = this . _heatmap . _r ;
308
- var size = this . context . map . getSize ( ) ;
310
+ var size = this . props . leaflet . map . getSize ( ) ;
309
311
310
312
var maxIntensity = this . props . max === undefined ? 1 : this . getMax ( this . props ) ;
311
313
312
- var maxZoom = this . props . maxZoom === undefined ? this . context . map . getMaxZoom ( ) : this . getMaxZoom ( this . props ) ;
314
+ var maxZoom = this . props . maxZoom === undefined ? this . props . leaflet . map . getMaxZoom ( ) : this . getMaxZoom ( this . props ) ;
313
315
314
- var v = 1 / Math . pow ( 2 , Math . max ( 0 , Math . min ( maxZoom - this . context . map . getZoom ( ) , 12 ) ) ) ;
316
+ var v = 1 / Math . pow ( 2 , Math . max ( 0 , Math . min ( maxZoom - this . props . leaflet . map . getZoom ( ) , 12 ) ) / 2 ) ;
315
317
316
318
var cellSize = r / 2 ;
317
- var panePos = this . context . map . _getMapPanePos ( ) ;
319
+ var panePos = this . props . leaflet . map . _getMapPanePos ( ) ;
318
320
var offsetX = panePos . x % cellSize ;
319
321
var offsetY = panePos . y % cellSize ;
320
322
var getLat = this . props . latitudeExtractor ;
@@ -383,7 +385,7 @@ var HeatmapLayer = function (_MapLayer) {
383
385
return roundResults ( accumulateInGrid ( points , leafletMap , getBounds ( leafletMap ) ) ) ;
384
386
} ;
385
387
386
- var data = getDataForHeatmap ( this . props . points , this . context . map ) ;
388
+ var data = getDataForHeatmap ( this . props . points , this . props . leaflet . map ) ;
387
389
388
390
this . _heatmap . clear ( ) ;
389
391
this . _heatmap . data ( data ) . draw ( this . getMinOpacity ( this . props ) ) ;
@@ -404,9 +406,7 @@ var HeatmapLayer = function (_MapLayer) {
404
406
} ;
405
407
406
408
return HeatmapLayer ;
407
- } ( _reactLeaflet . MapLayer ) ;
408
-
409
- HeatmapLayer . propTypes = {
409
+ } ( _reactLeaflet . MapLayer ) , _class . propTypes = {
410
410
points : _propTypes2 . default . array . isRequired ,
411
411
longitudeExtractor : _propTypes2 . default . func . isRequired ,
412
412
latitudeExtractor : _propTypes2 . default . func . isRequired ,
@@ -421,5 +421,4 @@ HeatmapLayer.propTypes = {
421
421
minOpacity : _propTypes2 . default . number ,
422
422
blur : _propTypes2 . default . number ,
423
423
gradient : _propTypes2 . default . object
424
- } ;
425
- exports . default = HeatmapLayer ;
424
+ } , _temp ) ) ;
0 commit comments