Skip to content

Commit ac85ca8

Browse files
author
Jack Carter
committed
Add support for marker labels
1 parent 6fa8036 commit ac85ca8

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ if __name__ == "__main__":
129129
- **lng**: The longitutde coordinate for centering the map.
130130
- **zoom**: The zoom level. Defaults to `13`.
131131
- **maptype**: The map type - `ROADMAP`, `SATELLITE`, `HYBRID`, `TERRAIN`. Defaults to `ROADMAP`.
132-
- **markers**: Markers array of tuples having (**lat**, **lng**, infobox, icon). Defaults to `None`.
133-
- or **markers**: a list of dicts containing **icon, lat, lng, infobox**.
132+
- **markers**: Markers array of tuples having (**lat**, **lng**, infobox, icon, label). Defaults to `None`.
133+
- or **markers**: a list of dicts containing **lat**, **lng**, infobox, icon, label.
134134
- or **markers**: Markers dictionary with icon urls as keys and markers array as values.
135135
- **varname**: The instance variable name.
136136
- **style**: A string containing CSS styles. Defaults to `"height:300px;width:300px;margin:0;"`.
@@ -223,6 +223,39 @@ Here's an example snippet of code:
223223
Which results in something like the following map:
224224
<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">
225225

226+
### Label
227+
228+
Here's an example snippet of code:
229+
```python
230+
231+
Map(
232+
identifier="labelsmap",
233+
lat=37.4419,
234+
lng=-122.1419,
235+
markers=[
236+
{
237+
'lat': 37.4500,
238+
'lng': -122.1350,
239+
'label': "X"
240+
},
241+
{
242+
'lat': 37.4419,
243+
'lng': -122.1419,
244+
'label': "Y"
245+
},
246+
{
247+
'lat': 37.4300,
248+
'lng': -122.1400,
249+
'label': "Z"
250+
}
251+
]
252+
)
253+
254+
```
255+
256+
Which results in something like the following map:
257+
<img width="271" alt="Map showing markers with labels" src="https://user-images.githubusercontent.com/708882/92332217-a3363280-f041-11ea-975c-0ac9413ada68.png">
258+
226259
### Fit all markers within bounds
227260

228261
Allow users to easily fit all markers within view on page load

flask_googlemaps/templates/googlemaps/gmapjs.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
position: new google.maps.LatLng(raw_markers[i].lat, raw_markers[i].lng),
6060
map: {{gmap.varname}},
6161
icon: raw_markers[i].icon,
62-
title: raw_markers[i].title ? raw_markers[i].title : null
62+
title: raw_markers[i].title ? raw_markers[i].title : null,
63+
label: raw_markers[i].label ? raw_markers[i].label : null
6364
});
6465

6566
if(raw_markers[i].infobox)

0 commit comments

Comments
 (0)