Skip to content

Commit 41ebbbe

Browse files
authored
Merge pull request #58 from mattdavis1121/master
Add fitbounds feature to README
2 parents 3574001 + 837a674 commit 41ebbbe

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,39 @@ Here's an example snippet of code:
213213
Which results in something like the following map:
214214
<img width="1439" alt="screen shot 2015-07-29 at 2 41 52 pm" src="https://cloud.githubusercontent.com/assets/8108300/8969650/13b0de7a-3602-11e5-9ed0-9f328ac9253f.png">
215215

216+
### Fit all markers within bounds
217+
Allow users to easily fit all markers within view on page load
218+
219+
#### Without bounds
220+
```python
221+
@app.route('/map-unbounded/')
222+
def map_unbounded():
223+
"""Create map with markers out of bounds."""
224+
locations = [] # long list of coordinates
225+
map = Map(
226+
lat=locations[0].latitude,
227+
lng=locations[0].longitude,
228+
markers=[(loc.latitude, loc.longitude) for loc in locations]
229+
)
230+
return render_template('map.html', map=map)
231+
```
232+
![image](https://user-images.githubusercontent.com/14223309/29294427-24a8d4e0-8104-11e7-967b-0c55c20d0f7c.png)
233+
234+
#### With bounds
235+
```python
236+
@app.route('/map-bounded/')
237+
def map_bounded():
238+
"""Create map with all markers within bounds."""
239+
locations = [] # long list of coordinates
240+
map = Map(
241+
lat=locations[0].latitude,
242+
lng=locations[0].longitude,
243+
markers=[(loc.latitude, loc.longitude) for loc in locations],
244+
fit_markers_to_bounds = True
245+
)
246+
return render_template('map.html', map=map)
247+
```
248+
![image](https://user-images.githubusercontent.com/14223309/29294483-6ac3e532-8104-11e7-988c-5c19d700fe5b.png)
216249

217250
### Run the example app
218251

0 commit comments

Comments
 (0)