@@ -192,6 +192,7 @@ def __init__(self, location=None, width='100%', height='100%',
192
192
'stamenterrain' , 'stamentoner' ,
193
193
'stamenwatercolor' ,
194
194
'cartodbpositron' , 'cartodbdark_matter' ]
195
+
195
196
self .tile_types = {}
196
197
for tile in self .default_tiles :
197
198
tile_path = 'tiles/%s' % tile
@@ -357,6 +358,58 @@ def simple_marker(self, location=None, popup=None,
357
358
append = (icon , marker , popup_out , add_mark )
358
359
self .template_vars .setdefault (name , []).append (append )
359
360
361
+ @iter_obj ('div_mark' )
362
+ def div_markers (self , locations = None , popups = None , marker_size = 10 , popup_width = 300 ):
363
+ """Create a simple div marker on the map, with optional
364
+ popup text or Vincent visualization. Useful for marking points along a
365
+ line.
366
+
367
+ Parameters
368
+ ----------
369
+ locations: list of locations, where each location is an array
370
+ Latitude and Longitude of Marker (Northing, Easting)
371
+ popup: list of popups, each popup should be a string or tuple, default 'Pop Text'
372
+ Input text or visualization for object. Can pass either text,
373
+ or a tuple of the form (Vincent object, 'vis_path.json')
374
+ It is possible to adjust the width of text/HTML popups
375
+ using the optional keywords `popup_width`. (Leaflet default is 300px.)
376
+ marker_size
377
+ default is 5
378
+
379
+ Returns
380
+ -------
381
+ Marker names and HTML in obj.template_vars
382
+
383
+ Example
384
+ -------
385
+ >>>map.div_markers(locations=[[37.421114, -122.128314], [37.391637, -122.085416], [37.388832, -122.087709]], popups=['1437494575531', '1437492135937', '1437493590434'])
386
+
387
+ """
388
+ call_cnt = self .mark_cnt ['div_mark' ]
389
+ if locations is None or popups is None :
390
+ raise RuntimeError ("Both locations and popups are mandatory" )
391
+ for (point_cnt , (location , popup )) in enumerate (zip (locations , popups )):
392
+ marker_num = 'div_marker_{0}_{1}' .format (call_cnt , point_cnt )
393
+
394
+ icon_temp = self .env .get_template ('static_div_icon.js' )
395
+ icon_name = marker_num + "_icon"
396
+ icon = icon_temp .render ({'icon_name' : icon_name ,
397
+ 'size' : marker_size })
398
+
399
+ mark_temp = self .env .get_template ('simple_marker.js' )
400
+ # Get marker and popup.
401
+ marker = mark_temp .render ({'marker' : marker_num ,
402
+ 'lat' : location [0 ],
403
+ 'lon' : location [1 ],
404
+ 'icon' : "{'icon':" + icon_name + "}"
405
+ })
406
+
407
+ popup_out = self ._popup_render (popup = popup , mk_name = 'div_marker_{0}_' .format (call_cnt ),
408
+ count = point_cnt , width = popup_width )
409
+ add_mark = 'map.addLayer(div_marker_{0}_{1})' .format (call_cnt , point_cnt )
410
+ append = (icon , marker , popup_out , add_mark )
411
+ self .template_vars .setdefault ('div_markers' , []).append (append )
412
+
360
413
@iter_obj ('line' )
361
414
def line (self , locations ,
362
415
line_color = None , line_opacity = None , line_weight = None ,
0 commit comments