Skip to content

Commit

Permalink
Update the UI to respond to the dynamically calculated zoom limits
Browse files Browse the repository at this point in the history
These changes feed the dynamically calculated zoom limits into the Map
component.

The addition of the "key" attribute is to get around the fact that
minZoom and maxZoom are not "dynamically" updated by the React-Leaflet
bindings. This forces react to completely recreate the map component. It
is not a very efficient choice, but it will do for now.
  • Loading branch information
andrewdodd committed Jul 23, 2019
1 parent 63943ac commit 13577a1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ui/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ class TodoApp extends React.Component {
onClick={e => {
console.log('clicked', e.latlng)
}}
key={mapId} // force minZoom/maxZoom etc to be reset by forcing React to create a new map (NB: not very efficient)
bounds={mapImage.geo_bounds}
zoom={12}
maxBounds={mapImage.geo_bounds}
// Allow 2 extra zooms, and prevent the last 2 extra zoom outs
minZoom={mapImage.minZoom + 2}
maxZoom={mapImage.maxZoom + 2}
style={{
height: '800px',
width: '100%',
Expand Down

0 comments on commit 13577a1

Please sign in to comment.