Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Test CustomIcon."""
self.setup()
icon_image = 'http://leafletjs.com/docs/images/leaf-green.png'
shadow_image = 'http://leafletjs.com/docs/images/leaf-shadow.png'
self.m = folium.Map([45, -100], zoom_start=4)
i = folium.features.CustomIcon(icon_image,
icon_size=(38, 95),
icon_anchor=(22, 94),
shadow_image=shadow_image,
shadow_size=(50, 64),
shadow_anchor=(4, 62),
popup_anchor=(-3, -76),)
mk = folium.Marker([45, -100], icon=i,
popup=folium.Popup('Hello'))
self.m.add_child(mk)
self.m._parent.render()
bounds = self.m.get_bounds()
assert bounds == [[45, -100], [45, -100]], bounds
def test_feature_group(self):
"""Test FeatureGroup."""
m = folium.Map()
feature_group = folium.FeatureGroup()
feature_group.add_child(folium.Marker([45, -30],
popup=folium.Popup('-30')))
feature_group.add_child(folium.Marker([45, 30],
popup=folium.Popup('30')))
m.add_child(feature_group)
m.add_child(folium.LayerControl())
m._repr_html_()
bounds = m.get_bounds()
assert bounds == [[45, -30], [45, 30]], bounds
def test_marker_popups():
m = Map()
folium.Marker([45, -180], popup='-180').add_to(m)
folium.Marker([45, -120], popup=Popup('-120')).add_to(m)
folium.RegularPolygonMarker([45, -60], popup='-60').add_to(m)
folium.RegularPolygonMarker([45, 0], popup=Popup('0')).add_to(m)
folium.CircleMarker([45, 60], popup='60').add_to(m)
folium.CircleMarker([45, 120], popup=Popup('120')).add_to(m)
folium.CircleMarker([45, 90], popup=Popup('90'), weight=0).add_to(m)
m._repr_html_()
bounds = m.get_bounds()
assert bounds == [[45, -180], [45, 120]], bounds
def test_feature_group(self):
"""Test FeatureGroup."""
m = folium.Map()
feature_group = folium.FeatureGroup()
feature_group.add_child(folium.Marker([45, -30],
popup=folium.Popup('-30')))
feature_group.add_child(folium.Marker([45, 30],
popup=folium.Popup('30')))
m.add_child(feature_group)
m.add_child(folium.LayerControl())
m._repr_html_()
bounds = m.get_bounds()
assert bounds == [[45, -30], [45, 30]], bounds
coords = info['coordinates']
coords = inverse_coordinates(coords)
if data:
# Try to get the image scale
scale = data.projection().nominalScale().getInfo() if not scale else scale
# Reduce if computed scale is too big
scale = 1 if scale > 500 else scale
values = tools.image.get_value(data, geometry, scale, 'client')
val_str = ''
for key, val in values.items():
val_str += '<b>{}:</b> {}<br>'.format(key, val)
marker = folium.Marker(location=coords,
popup=folium.Popup(val_str))
else:
marker = folium.Marker(location=coords)
self.add_child(marker)
for tweet in results['statuses']:
if tweet.get('geo') is None:
continue
photo_lat, photo_lon = tweet['geo']['coordinates']
media_url = next((e[0]['media_url'] for e in tweet['entities'] if 'media' in e), None)
if media_url is None:
continue
photos = [media_url]
distance = vincenty((lat, lon), (photo_lat, photo_lon)).meters
if int(distance) <= radius:
iframe = get_frame(photos)
folium.CircleMarker(
location=[photo_lat, photo_lon],
radius=3,
popup=folium.Popup(iframe, max_width=2650),
color='Red',
fill_opacity=1.0,
fill_color='Red'
).add_to(maps)
return maps
u = user
try:
ncluster = row[constants.CLUSTER]
cl = '<br>Cluster: {}'.format(ncluster)
color = get_color(ncluster)
except (KeyError, NameError):
cl = ''
fpoly = folium.RegularPolygonMarker([la, lo],
radius=radius,
color=color,
fill_color=color,
fill_opacity=opacity
)
if popup:
popup = folium.Popup('User: {}<br>Coord: <a href="https://www.google.co.uk/maps/place/{},{}">{}, {}</a><br>Arr: {}<br>Dep: {}{}' \
.format(u, la, lo, np.round(la, 4), np.round(lo, 4),
pd.datetime.strftime(t0, '%Y/%m/%d %H:%M'),
pd.datetime.strftime(t1, '%Y/%m/%d %H:%M'), cl), max_width=300)
fpoly = fpoly.add_child(popup)
fpoly.add_to(map_f)
return map_f
name = 'origin: %s' % O.replace('\'', '_')
T_D = [[T, D] for D, T in OD[[constants.DESTINATION, constants.FLOW]].values]
trips_info = '<br>'.join(["flow to %s: %s" %
(dd.replace('\'', '_'), int(tt)) \
for tt, dd in sorted(T_D, reverse=True)[:num_od_popup]])
geom = fdf.get_geometry(O)
lonO, latO = utils.get_geom_centroid(geom)
fmarker = folium.CircleMarker([latO, lonO],
radius=radius_origin_point,
weight=2,
color=color_origin_point,
fill=True, fill_color=color_origin_point
)
if tile_popup:
popup = folium.Popup(name+'<br>'+trips_info, max_width=300)
fmarker = fmarker.add_child(popup)
fmarker.add_to(map_f)
return map_f
if coordinates in repeats:
folium.Marker([camera['location']['latitude'], camera['location']['longitude']], icon=shodan_icon,
popup=popup).add_to(marker_cluster)
else:
folium.Marker([camera['location']['latitude'], camera['location']['longitude']], icon=shodan_icon,
popup=popup,
).add_to(folium_map)
repeats.append(coordinates)
if service == 'instagram':
insta_icon = "http://icons-for-free.com/free-icons/png/512/2329265.png"
for photo, coordinates in results.items():
icon = folium.features.CustomIcon(insta_icon, icon_size=(35, 35)) # bug
html = '<img src="{}" style="width:100%; height:100%;">'.format(str(photo))
popup = folium.Popup(branca.element.IFrame(html=html, width=420, height=320), max_width=2137)
if coordinates in repeats:
folium.Marker([coordinates[0], coordinates[1]], icon=icon,
popup=popup).add_to(marker_cluster)
else:
folium.Marker([coordinates[0], coordinates[1]], icon=icon,
popup=popup).add_to(folium_map)
repeats.append(coordinates)
if service == 'flickr':
flickr_icon = "http://www.myiconfinder.com/uploads/iconsets/f425a318030877cc09cb7832bea3e2c8.png"
for flickr_photo in results:
icon = folium.features.CustomIcon(flickr_icon, icon_size=(35, 35))
str_coordinates = str(flickr_photo['latitude']) + ',' + str(flickr_photo['longitude'])