Please make sure to check the following boxes before submitting an issue. Thanks!
map component should update max zoom properly when max zoom update .
map component did not update max zoom properly when max zoom update .
example code refer to https://www.webpackbin.com/bins/-KpPQllgV40qn3E7hrxq
Please only check the boxes if you have actually done what they say... this is the expected behavior, as documented.
@PaulLeCam I have actually done all the boxes, but the problem still exist. Could you try the the example I mentioned above?
@PaulLeCam Did you mean if I want to properly update the maxZoom , I should directly write some code such as this.refs.map.leafletElement.setMaxZoom(max)?
Yes, it's not supported as a "dynamic property" as documented in the link above, so there is no logic to update the value from the Map's props to the Leaflet element.
uhh...okay, thanks.
If I would like to make some property dynamic lets say minNativeZoom on TileLayer dynamic what would be the best approach to that?
@valstu extend the component and implement it yourself by overriding updateLeafletElement or fork the project and apply the fix directly. I've taken the former approach, it's relatively straight forward. The difficult part is remembering which props are already dynamic and which aren't.
If it can save you some time (v2.x)
import L from 'leaflet';
import { Map, withLeaflet } from 'react-leaflet';
class CustZoomMap extends Map {
constructor(props) {
super(props)
}
componentDidUpdate(prevProps) {
super.componentDidUpdate(prevProps)
this.leafletElement.setMinZoom(this.props.minZoom)
}
}
export default withLeaflet(CustZoomMap);