Esempio n. 1
0
def print_geojson(geojson, limit=100):
    center = None
    j = json.load(StringIO(geojson))
    layer_group = LayerGroup()

    features = j['features']
    if limit is not None:
        features = features[0:limit]

    for f in features:
        location = (f['geometry']['coordinates'][1],
                    f['geometry']['coordinates'][0])
        marker = Marker(location=location)
        marker.popup = HTML(str(f['properties']))
        layer_group.add_layer(marker)
        if not center:
            center = location

    if not center:
        center = (0, 0)

    m = Map(layers=(basemap_to_tiles(basemaps.OpenStreetMap.Mapnik), ),
            center=center,
            zoom=8)

    m.add_layer(layer_group)
    return m
Esempio n. 2
0
def add_route_to_map(route, some_map, color='blue'):
    """
    Add a route from the HERE REST API to the given map.
    
    This includes markers for all points where a maneuver is needed, like 'turn left'.
    And it includes a path with lat/lons from start to end and little circle markers
    around them.
    """
    path_positions = list(chunks(route[0]['shape'], 2))
    maneuvers = {
        (man['position']['latitude'], man['position']['longitude']): man['instruction']
            for man in route[0]['leg'][0]['maneuver']}

    polyline = Polyline(
        locations=path_positions,
        color=color,
        fill=False
    )
    some_map += polyline
    
    for lat, lon in path_positions:
        if (lat, lon) in maneuvers:
            some_map += CircleMarker(location=(lat, lon), radius=2)
            
            marker = Marker(location=(lat, lon), draggable=False)
            message1 = HTML()
            message1.value = maneuvers[(lat, lon)]
            marker.popup = message1
            some_map += marker
        else:
            some_map += CircleMarker(location=(lat, lon), radius=3)
Esempio n. 3
0
    def show_stations_on_map(self,list_inc,list_process,list_filters,
     opt_params):
        """ Returns an interactive map of source and stations, use only in 
        Jupyter Notebooks.  

        Inputs:
            | list_inc: list of incidents
            | list_process: list of processes, one list per incident
            | list filters: list of filters defined for stations
            | opt_params: optional parameters (dictionary)

        Optional parameters:

        """
                
        records = self._extract_records(list_inc, list_process, list_filters)

        if not records:
            LOGGER.warning("There are no records to satisfy the provided"
             " filters.")
            return

        m = Map(
            basemap=basemap_to_tiles(basemaps.Esri.WorldImagery, "2020-04-08"),
            center = (Station.pr_source_loc[0],Station.pr_source_loc[1]),
            zoom = 8,
            close_popup_on_click=True
        )

        for i in records:
            if not i[0]:
                continue
            lat = i[0].station.lat
            lon = i[0].station.lon
            marker = Marker(location=(lat, lon), draggable=False,
             icon=AwesomeIcon(name="map-pin", marker_color='green',
             icon_color='darkgreen'), opacity=0.8)
            m.add_layer(marker)
            message = HTML()
            message.value = i[0].station.inc_st_name[list_inc[0]]
            marker.popup = message

        m.add_layer(Marker(icon=AwesomeIcon(name="star",
         marker_color='red', icon_color='darkred'),
         location=(Station.pr_source_loc[0],Station.pr_source_loc[1]),
         draggable=False))
        
        return m
Esempio n. 4
0
File: vgan.py Progetto: cyhsu/vgan
def createLeafletMarker(m, mission, MapGliderLocation, popup=None):
    icon1 = AwesomeIcon(name='paper-plane-o',
                        marker_color='red',
                        icono_color='black',
                        icon_size=(2, 2),
                        spin=False)

    marker = Marker(
        icon=icon1,
        name=mission,
        location=(MapGliderLocation[-1][0], MapGliderLocation[-1][1] - 0.001),
        draggable=False,
        opacity=0.3,
        rise_on_hover=True,
    )
    if popup:
        marker.popup = widgets.HTML('<h1><u>{}</u></h1>'.format(mission))
    m.add_layer(marker)
    return m
Esempio n. 5
0
def point_leaflet(point: "PointMixin", **kwargs) -> Marker:
    """Returns a Leaflet layer to be directly added to a Map.

    .. warning::
        This is only available if the Leaflet `plugin <plugins.html>`_ is
        activated. (true by default)

    The elements passed as kwargs as passed as is to the Marker constructor.
    """

    default = dict()
    if hasattr(point, "name"):
        default["title"] = point.name

    kwargs = {**default, **kwargs}
    marker = Marker(location=(point.latitude, point.longitude), **kwargs)

    label = HTML()
    label.value = repr(point)
    marker.popup = label

    return marker
Esempio n. 6
0
 def build_map(self, click_handler: Callable[[Dict[str, Any]],
                                             None]) -> Map:
     mean_lat = self.x_data[self.lat_key].values.mean()
     mean_lng = self.x_data[self.lon_key].values.mean()
     # create the map
     m = Map(center=(mean_lat, mean_lng),
             zoom=4,
             basemap=basemaps.Stamen.Terrain)
     m.layout.height = '1200px'
     # show trace
     markers = []
     for k in self.marker_info:
         message = self.create_popup(k)
         marker = Marker(location=k, draggable=False)
         marker.on_click(click_handler)
         marker.popup = message
         markers.append(marker)
     marker_cluster = MarkerCluster(markers=markers)
     # not sure whether we could register once instead of each marker:
     # marker_cluster.on_click(click_handler)
     m.add_layer(marker_cluster)
     # m.add_control(FullScreenControl())
     return m
Esempio n. 7
0
has_data_provs = data['省市'].unique()
vaccinations_affected = data_sub['疫苗名称'].unique()

with open(os.path.join('../src', 'zh-mainland-provinces.geojson'), 'r', encoding='utf8') as f:
    geo_data = json.load(f)

for feature in geo_data['features']:
    if feature['properties']['name_local'] is None:
        feature['properties']['name_local'] = u"青海|青海"


m = Map(center=(40, 105), zoom=4, layout=Layout(width='100%', height='700px'))
vac_name = vaccinations_affected[0]
message = HTML()
message.value = '<ins>图解:</ins><p>红色标识该省疫苗生产出自长春系公司,<br/>颜色越深代表占比越高。<br/>绿色表示该省疫苗生产完全出自其他公司。<br/>灰色代表该省暂无数据。</p>'

marker = Marker(location=(20, 135), draggable=False)
marker.popup = message
# m.add_layer(marker)

title = Popup(
        location=(50, 105),
        child=HTML(value='<h4>{}</h4>'.format(vac_name)),
        close_button=False,
        auto_close = False,
)
m.add_layer(title)
geo_json = GeoJSON(data=prepare_geo_json(vac_name, data, geo_data, has_data_provs),
                   name=vac_name)
m.add_layer(geo_json)
m
Esempio n. 8
0
    name="GTS",
    position="bottomright",
)
m.add_control(legend)


def make_popup(row):
    classes = "table table-striped table-hover table-condensed table-responsive"
    return pd.DataFrame(row[["met", "wave", "type", "name", "pgm"]]).to_html(
        classes=classes
    )

for k, row in map_df.iterrows():
    if (row["met"] + row["wave"]) > 0:
        location = row["lat"], row["lon"]
        if row["met"] == 0:
            color = "red"
        elif row["wave"] == 0:
            color = "orange"
        else:
            color = "green"
        marker = Marker(
            draggable=False,
            icon=AwesomeIcon(name="life-ring", marker_color=color),
            location=location,
        )
        msg = HTML()
        msg.value = make_popup(row)
        marker.popup = msg
        m.add_layer(marker)
m
                  delay=1000,
                  color='#9500ff',
                  pulse_color='#9500ff')

# In[18]:

map.add_layer(my_path)
start_marker = Marker(location=(56.847962835674466, 35.9070110321045))
map.add_layer(start_marker)
finish_marker = Marker(location=(56.881189988867625, 35.927454334450935))
map.add_layer(finish_marker)
start = HTML()
finish = HTML()
start.value = 'Start'
finish.value = 'End'
start_marker.popup = start
finish_marker.popup = finish
zoom_slider = IntSlider(description='Zoom', min=11, max=15, value=14)
jslink((zoom_slider, 'value'), (m, 'zoom'))

# In[19]:

widget_control = WidgetControl(widget=zoom_slider, position='topright')
map.add_control(widget_control)
display(map)

# In[20]:

print(str(map))

# In[21]:
for i in range(len(features)):
    location = (features[i]['geometry']['coordinates'][1],
                features[i]['geometry']['coordinates'][0])
    nazvy = features[i]['properties']['Nazev']
    id = features[i]['properties']['gml_id']
    html = """
    <p>
      <h4><b>Okres</b>:        """ + " ".join(nazvy) + """</h4>
    </p>
    <p>
      <h5><b>ID</b>:        """ + " ".join(id) + """</h5>
    </p>
    """
    marker = Marker(location=location)
    # Popup associated to a layer
    marker.popup = HTML(html)
    m.add_layer(marker)

# %%
display(m)

# %%
G = apply_function(compilable_node_dictionary(admunit_cz), 'admunit__tree')

# %%
list(find_neighbors_level(G.reverse(), '3201', 4))

# %%
lpis_cz__metadata = MetaData('LPIS v okrese Benesov', [{
    "url":
    "http://eagri.cz/public/app/eagriapp/lpisdata/[lpis_cz__posledni_aktualizace]-{admunit__tree__neighbors__3201__4}-DPB-SHP.zip",
Esempio n. 11
0
def visualize():
    center = location_latlongs[1]

    m = Map(center=center, zoom=8)
    icon1 = Icon(
        icon_url='https://img.icons8.com/ultraviolet/40/000000/map-pin.png',
        icon_size=[40, 40],
        icon_anchor=[20, 40])
    icon2 = Icon(
        icon_url='https://img.icons8.com/officel/40/000000/map-pin.png',
        icon_size=[40, 40],
        icon_anchor=[20, 40])
    icon3 = Icon(
        icon_url=
        'http://icons.iconarchive.com/icons/custom-icon-design/flatastic-6/256/Circle-icon.png',
        icon_size=[10, 10],
        icon_anchor=[5, 5],
        shadow_size=[5, 5])

    line = Polyline(locations=[[
        path_latlongs,
    ]],
                    color="#669df6",
                    fill=False,
                    weight=2,
                    stroke=True)

    m.add_layer(line)

    style = {'text-align': 'left', 'description_width': '150px'}
    i = 0
    while i < len(location_latlongs):
        if i == 0:
            message = HTML()
            message.placeholder = "Source"
            message.description = "Source" + "<br>Node ID: " + location_latlongs[
                i][2] + "<br>Lat:   " + str(
                    location_latlongs[i][1]) + "<br>Long:  " + str(
                        location_latlongs[i][0])
            message.style = style
            marker = Marker(location=location_latlongs[i],
                            draggable=False,
                            title="Source",
                            icon=icon1,
                            rise_on_hover=True,
                            z_index_offset=100)
            m.add_layer(marker)
            marker.popup = message

        elif (len(location_latlongs) - i) == 1:
            message = HTML()
            message.placeholder = "Destination"
            message.description = "Destination" + "<br>Node ID: " + location_latlongs[
                i][2] + "<br>Lat:   " + str(
                    location_latlongs[i][1]) + "<br>Long:  " + str(
                        location_latlongs[i][0])
            message.style = style
            marker = Marker(location=location_latlongs[i],
                            draggable=False,
                            title="Destination",
                            icon=icon2,
                            rise_on_hover=True)
            m.add_layer(marker)
            marker.popup = message

        else:
            message = HTML()
            message.placeholder = "Waypoint"
            message.description = "Waypoint: " + str(
                i) + "" + "<br>Node ID: " + location_latlongs[i][
                    2] + "<br>Lat:   " + str(
                        location_latlongs[i][1]) + "<br>Long:  " + str(
                            location_latlongs[i][0])
            message.style = style
            marker = Marker(location=location_latlongs[i],
                            draggable=False,
                            icon=icon3,
                            title="Waypoint",
                            rise_on_hover=True)
            m.add_layer(marker)
            marker.popup = message
        i += 1

    return (m)