How to use the folium.Marker function in folium

To help you get started, we’ve selected a few folium examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-visualization / folium / tests / test_utilities.py View on Github external
def test_get_obj_in_upper_tree():
    m = Map()
    fg = FeatureGroup().add_to(m)
    marker = Marker(location=(0, 0)).add_to(fg)
    assert get_obj_in_upper_tree(marker, FeatureGroup) is fg
    assert get_obj_in_upper_tree(marker, Map) is m
    # The search should only go up, not down:
    with pytest.raises(ValueError):
        assert get_obj_in_upper_tree(fg, Marker)
    with pytest.raises(ValueError):
        assert get_obj_in_upper_tree(marker, Popup)
github python-visualization / folium / tests / test_utilities.py View on Github external
def test_deep_copy():
    m = Map()
    fg = FeatureGroup().add_to(m)
    Marker(location=(0, 0)).add_to(fg)
    m_copy = deep_copy(m)

    def check(item, item_copy):
        assert type(item) is type(item_copy)
        assert item._name == item_copy._name
        for attr in item.__dict__.keys():
            if not attr.startswith('_'):
                assert getattr(item, attr) == getattr(item_copy, attr)
        assert item is not item_copy
        assert item._id != item_copy._id
        for child, child_copy in zip(item._children.values(),
                                     item_copy._children.values()):
            check(child, child_copy)

    check(m, m_copy)
github psychemedia / ipython_magic_folium / folium_magic / folium_magic.py View on Github external
else:
                #Just plot the boundary
                folium.GeoJson( args.geojson, name='geojson' ).add_to(m)

        if self._check_topojson(args.topojson):
            with open( args.topojson ) as tf:
                m.choropleth(tf,topojson='objects.collection', smooth_factor=0.5)
                              
        if args.marker is not None:
            if len(marker)==3:
                folium.Marker(latlong,popup=str(marker[2])).add_to(m)
            else:
                folium.Marker(latlong).add_to(m)

        if args.address is not None:
            folium.Marker(address_latlong,popup=str(args.address)).add_to(m)
            
        for marker in markers:
            folium.Marker(marker['latlong'],popup=marker['popup']).add_to(m)
            
        if args.clustermarkers is not None:
            marker_cluster = MarkerCluster().add_to(m)
            for marker in clustermarkers:
                folium.Marker(marker['latlong'] ,popup=marker['popup']).add_to(marker_cluster)
                
        return m
github gee-community / gee_tools / geetools / ui / maptool.py View on Github external
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)
github psychemedia / ipython_magic_folium / folium_magic / folium_magic.py View on Github external
key_on=args.key,
                                 fill_color=args.palette, fill_opacity=args.opacity
                                )
            else:
                #Just plot the boundary
                folium.GeoJson( args.geojson, name='geojson' ).add_to(m)

        if self._check_topojson(args.topojson):
            with open( args.topojson ) as tf:
                m.choropleth(tf,topojson='objects.collection', smooth_factor=0.5)
                              
        if args.marker is not None:
            if len(marker)==3:
                folium.Marker(latlong,popup=str(marker[2])).add_to(m)
            else:
                folium.Marker(latlong).add_to(m)

        if args.address is not None:
            folium.Marker(address_latlong,popup=str(args.address)).add_to(m)
            
        for marker in markers:
            folium.Marker(marker['latlong'],popup=marker['popup']).add_to(m)
            
        if args.clustermarkers is not None:
            marker_cluster = MarkerCluster().add_to(m)
            for marker in clustermarkers:
                folium.Marker(marker['latlong'] ,popup=marker['popup']).add_to(marker_cluster)
                
        return m
github TaipanRex / pyvisgraph / examples / 3_plot_path_on_interactive_map.py View on Github external
start_point = vg.Point(12.568337, 55.676098) # Copenhagen
end_point = vg.Point(103.851959, 1.290270) # Singapore

# Load the visibility graph file If you do not have this, please run
# 1_build_graph_from_shapefiles.py first.
graph = vg.VisGraph()
graph.load('GSHHS_c_L1.graph')

# Calculate the shortest path
shortest_path  = graph.shortest_path(start_point, end_point)

# Plot of the path using folium
geopath = [[point.y, point.x] for point in shortest_path]
geomap  = folium.Map([0, 0], zoom_start=2)
for point in geopath:
    folium.Marker(point, popup=str(point)).add_to(geomap)
folium.PolyLine(geopath).add_to(geomap)

# Add a Mark on the start and positions in a different color
folium.Marker(geopath[0], popup=str(start_point), icon=folium.Icon(color='red')).add_to(geomap)
folium.Marker(geopath[-1], popup=str(end_point), icon=folium.Icon(color='red')).add_to(geomap)

# Save the interactive plot as a map
output_name = 'example_shortest_path_plot.html'
geomap.save(output_name)
print('Output saved to: {}'.format(output_name))
github bonzanini / Book-SocialMediaMiningPython / Chap02-03 / twitter_map_example.py View on Github external
def make_map(map_file):
    # Custom map
    sample_map = folium.Map(location=[50, 5],
                            zoom_start=5)
    # Marker for London
    london_marker = folium.Marker([51.5, -0.12],
                                  popup='London')
    london_marker.add_to(sample_map)
    # Marker for Paris
    paris_marker = folium.Marker([48.85, 2.35],
                                 popup='Paris')
    paris_marker.add_to(sample_map)
    # Save to HTML file
    sample_map.save(map_file)