File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,5 +36,38 @@ const createLeafletElement = (props: IProps, context: LeafletContextInterface) =
3636 return { instance, context } ;
3737}
3838
39+ const updateLeafletElement = (
40+ instance : L . GridLayer ,
41+ props : IProps ,
42+ prevProps : IProps
43+ ) => {
44+ let prevGoogleMapsAddLayers = prevProps . googleMapsAddLayers
45+ ? prevProps . googleMapsAddLayers . map ( ( addLayer : IGoogleMapsAddLayer ) => addLayer . name )
46+ : [ ] ;
47+ let currentGoogleMapsAddLayers = props . googleMapsAddLayers
48+ ? props . googleMapsAddLayers . map ( ( addLayer : IGoogleMapsAddLayer ) => addLayer . name )
49+ : [ ] ;
50+ if ( props . googleMapsAddLayers ) {
51+ props . googleMapsAddLayers . forEach ( ( layer ) => {
52+ if ( prevGoogleMapsAddLayers . indexOf ( layer . name ) === - 1 ) {
53+ ( instance as L . gridLayer . GoogleMutant ) . addGoogleLayer (
54+ layer . name ,
55+ layer . options
56+ ) ;
57+ }
58+ } ) ;
59+ if ( prevProps . googleMapsAddLayers )
60+ prevProps . googleMapsAddLayers . forEach ( ( layer ) => {
61+ if ( currentGoogleMapsAddLayers . indexOf ( layer . name ) === - 1 ) {
62+ ( instance as L . gridLayer . GoogleMutant ) . removeGoogleLayer ( layer . name ) ;
63+ }
64+ } ) ;
65+ }
66+
67+ updateGridLayer ( instance , props , prevProps ) ;
68+ } ;
3969
40- export default createLayerComponent < L . GridLayer , LayerProps & IProps > ( createLeafletElement , updateGridLayer ) ;
70+ export default createLayerComponent < L . GridLayer , LayerProps & IProps > (
71+ createLeafletElement ,
72+ updateLeafletElement
73+ ) ;
You can’t perform that action at this time.
0 commit comments