File tree Expand file tree Collapse file tree 3 files changed +24
-8
lines changed
Expand file tree Collapse file tree 3 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,15 @@ function isValid(num) {
7676 return ! isInvalid ( num ) ;
7777}
7878
79+ function safeRemoveLayer ( map , el ) {
80+ var _map$getPanes = map . getPanes ( ) ,
81+ overlayPane = _map$getPanes . overlayPane ;
82+
83+ if ( overlayPane . contains ( el ) ) {
84+ overlayPane . removeChild ( el ) ;
85+ }
86+ }
87+
7988function shouldIgnoreLocation ( loc ) {
8089 return isInvalid ( loc . lng ) || isInvalid ( loc . lat ) ;
8190}
@@ -124,7 +133,7 @@ var HeatmapLayer = function (_MapLayer) {
124133 return this ;
125134 } ,
126135 onRemove : function onRemove ( map ) {
127- map . getPanes ( ) . overlayPane . removeChild ( el ) ;
136+ safeRemoveLayer ( map , el ) ;
128137 }
129138 } ) ;
130139
@@ -191,7 +200,7 @@ var HeatmapLayer = function (_MapLayer) {
191200 } ;
192201
193202 HeatmapLayer . prototype . componentWillUnmount = function componentWillUnmount ( ) {
194- this . context . map . getPanes ( ) . overlayPane . removeChild ( this . _el ) ;
203+ safeRemoveLayer ( this . context . map , this . _el ) ;
195204 } ;
196205
197206 HeatmapLayer . prototype . fitBounds = function fitBounds ( ) {
Original file line number Diff line number Diff line change 2828 "author" : " Jeremiah Hall <npm@jeremiahrhall.com>" ,
2929 "license" : " MIT" ,
3030 "peerDependencies" : {
31- "leaflet" : " ^ 1.0.2 " ,
32- "react-leaflet" : " ^ 1.0.0" ,
33- "react" : " ^ 15.4.1" ,
34- "react-dom" : " ^ 15.4.1"
31+ "leaflet" : " >= 1.0.0 " ,
32+ "react-leaflet" : " >= 1.0.0" ,
33+ "react" : " >= 15.4.1" ,
34+ "react-dom" : " >= 15.4.1"
3535 },
3636 "devDependencies" : {
3737 "babel-cli" : " ^6.6.5" ,
Original file line number Diff line number Diff line change @@ -65,6 +65,13 @@ function isValid(num: number): boolean {
6565 return ! isInvalid ( num ) ;
6666}
6767
68+ function safeRemoveLayer ( map , el ) {
69+ const { overlayPane} = map . getPanes ( )
70+ if ( overlayPane . contains ( el ) ) {
71+ overlayPane . removeChild ( el ) ;
72+ }
73+ }
74+
6875function shouldIgnoreLocation ( loc : LngLat ) : boolean {
6976 return isInvalid ( loc . lng ) || isInvalid ( loc . lat ) ;
7077}
@@ -125,7 +132,7 @@ export default class HeatmapLayer extends MapLayer {
125132 return this ;
126133 } ,
127134 onRemove : function ( map ) {
128- map . getPanes ( ) . overlayPane . removeChild ( el ) ;
135+ safeRemoveLayer ( map , el )
129136 }
130137 } ) ;
131138
@@ -194,7 +201,7 @@ export default class HeatmapLayer extends MapLayer {
194201 }
195202
196203 componentWillUnmount ( ) : void {
197- this . context . map . getPanes ( ) . overlayPane . removeChild ( this . _el ) ;
204+ safeRemoveLayer ( this . context . map , this . _el ) ;
198205 }
199206
200207 fitBounds ( ) : void {
You can’t perform that action at this time.
0 commit comments