File tree Expand file tree Collapse file tree
HorizontalButtonGroupsControl
VerticalButtonGroupsControl Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " react-fengmap" ,
3- "version" : " 2.9.0 " ,
3+ "version" : " 2.9.1 " ,
44 "description" : " " ,
55 "author" : " Howard.Zuo" ,
66 "typings" : " typings/index.d.ts" ,
Original file line number Diff line number Diff line change @@ -125,6 +125,17 @@ class FengmapBase extends Component {
125125 } )
126126 }
127127
128+ _destroyAllChildren = map => {
129+ const { fengmapSDK } = this . props
130+ const { refs } = this
131+ if ( ! isArray ( refs ) ) {
132+ return
133+ }
134+ refs . forEach ( ref => {
135+ ref . current . unload ( map , fengmapSDK , this )
136+ } )
137+ }
138+
128139 componentDidMount ( ) {
129140 this . _loadMap ( this . props . mapId )
130141 if ( this . loadingTxt && this . loadingTxt . current ) {
@@ -145,6 +156,9 @@ class FengmapBase extends Component {
145156 if ( ! this . mapInstance ) {
146157 return
147158 }
159+
160+ this . _destroyAllChildren ( this . mapInstance )
161+
148162 EVENTS . forEach ( e => {
149163 this . mapInstance . off ( e )
150164 } )
Original file line number Diff line number Diff line change 11import React from 'react'
22
3- export default class FengmapBaseControl extends React . Component { }
3+ export default class FengmapBaseControl extends React . Component {
4+ load = ( ) => { }
5+ unload = ( ) => { }
6+ }
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ class HorizontalButtonGroupsControl extends React.Component {
155155 const { showGroups } = this . state
156156 const { showBtnCount } = ctrlOptions
157157
158- if ( ! showGroups ) {
158+ if ( ! showGroups || ! map || ! map . listFloors ) {
159159 return null
160160 }
161161
Original file line number Diff line number Diff line change @@ -151,7 +151,7 @@ class VerticalButtonGroupsControl extends React.Component {
151151 const { showGroups } = this . state
152152 const { showBtnCount } = ctrlOptions
153153
154- if ( ! showGroups ) {
154+ if ( ! showGroups || ! map || ! map . listFloors ) {
155155 return null
156156 }
157157
Original file line number Diff line number Diff line change @@ -37,10 +37,14 @@ class FengmapFloorControl extends FengmapBaseControl {
3737 }
3838
3939 this . resizeHandler = ( ) => {
40- setTimeout ( ( ) => {
41- this . setState ( {
42- showHorizontal : map . height < 450
43- } )
40+ this . resizeTimer = setTimeout ( ( ) => {
41+ try {
42+ this . setState ( {
43+ showHorizontal : map . height < 450
44+ } )
45+ } catch ( error ) {
46+ console . warn ( error . message )
47+ }
4448 } , 1000 )
4549 }
4650
@@ -55,6 +59,11 @@ class FengmapFloorControl extends FengmapBaseControl {
5559 setTimeout ( this . resizeHandler , 500 )
5660 }
5761
62+ unload = ( map , fengmapSDK , parent ) => {
63+ clearTimeout ( this . resizeTimer )
64+ window . removeEventListener ( 'resize' , this . resizeHandler )
65+ }
66+
5867 componentWillUnmount ( ) {
5968 window . removeEventListener ( 'resize' , this . resizeHandler )
6069 }
You can’t perform that action at this time.
0 commit comments