Пример #1
0
def run():
    global m, dc, center
    #    center = list(reversed(poly.centroid().coordinates().getInfo()))
    center = [51.0, 6.4]
    osm = basemap_to_tiles(basemaps.OpenStreetMap.Mapnik)
    ews = basemap_to_tiles(basemaps.Esri.WorldStreetMap)
    ewi = basemap_to_tiles(basemaps.Esri.WorldImagery)
    #    mb = TileLayer(url="https://api.mapbox.com/styles/v1/mapbox/satellite-streets-v9/tiles/256/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWNhbnR5IiwiYSI6ImNpcjRsMmJxazAwM3hoeW05aDA1cmNkNzMifQ.d2UbIugbQFk2lnU8uHwCsQ",
    #                   attribution = "<a href='https://www.mapbox.com/about/maps/'>Mapbox</a> © <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> <strong><a href='https://www.mapbox.com/map-feedback/' target='_blank'>Improve this map</a></strong>" )
    #    sm_control = SplitMapControl(left_layer=osm,right_layer=ewi)
    lc = LayersControl(position='topright')
    fs = FullScreenControl(position='topleft')
    mc = MeasureControl(position='topright', primary_length_unit='kilometers')

    m = Map(center=center,
            zoom=11,
            layout={'height': '500px'},
            layers=(ewi, ews, osm),
            controls=(mc, dc, lc, fs))
    #    m = Map(center=center, zoom=11, layout={'height':'500px'},controls=(lc,dc,fs,mc,sm_control))

    with w_out:
        w_out.clear_output()
        print('Algorithm output')
    display(m)
    return box
Пример #2
0
def run():
    global m,center
#    center = list(reversed(poly.centroid().coordinates().getInfo()))
    center = [51.0,6.4]
    osm = basemap_to_tiles(basemaps.OpenStreetMap.Mapnik)
    ews = basemap_to_tiles(basemaps.Esri.WorldStreetMap)
    ewi = basemap_to_tiles(basemaps.Esri.WorldImagery)
    
    dc = DrawControl(polyline={},circlemarker={})
    dc.rectangle = {"shapeOptions": {"fillColor": "#0000ff","color": "#0000ff","fillOpacity": 0.05}}
    dc.polygon = {"shapeOptions": {"fillColor": "#0000ff","color": "#0000ff","fillOpacity": 0.05}}
    dc.on_draw(handle_draw)
    
    lc = LayersControl(position='topright')
    fs = FullScreenControl(position='topleft')
    mc = MeasureControl(position='topright',primary_length_unit = 'kilometers')

    m = Map(center=center, zoom=11, layout={'height':'500px'},layers=(ewi,ews,osm),controls=(mc,dc,lc,fs))   
#    m = Map(center=center, zoom=11, layout={'height':'500px'},controls=(lc,dc,fs,mc,sm_control)) 

    with w_out:
        w_out.clear_output()
        print('Algorithm output')
    display(m) 
    return box
Пример #3
0
    def __init__(self, **kwargs):

        if "center" not in kwargs:
            kwargs["center"] = [40, -100]

        if "zoom" not in kwargs:
            kwargs["zoom"] = 4

        if "scroll_wheel_zoom" not in kwargs:
            kwargs["scroll_wheel_zoom"] = True

        super().__init__(**kwargs)

        if "height" not in kwargs:
            self.layout.height = "600px"
        else:
            self.layout.height = kwargs["height"]

        self.add_control(FullScreenControl())
        self.add_control(LayersControl(position="topright"))
        self.add_control(DrawControl(position="topleft"))
        self.add_control(MeasureControl())
        self.add_control(ScaleControl(position="bottomleft"))

        main_toolbar(self)

        if "google_map" not in kwargs:
            layer = TileLayer(
                url="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}",
                attribution="Google",
                name="Google Maps",
            )
            self.add_layer(layer)
        else:
            if kwargs["google_map"] == "ROADMAP":
                layer = TileLayer(
                    url="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}",
                    attribution="Google",
                    name="Google Maps",
                )
                self.add_layer(layer)
            elif kwargs["google_map"] == "HYBRID":
                layer = TileLayer(
                    url="https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}",
                    attribution="Google",
                    name="Google Satellite",
                )
                self.add_layer(layer)
Пример #4
0
 def _addControls(self):
     # Add Controls
     self._m.add_control(
         MeasureControl(position='bottomleft',
                        active_color='orange',
                        primary_length_unit='kilometers'))
     self._m.add_control(FullScreenControl())
     self._m.add_control(ScaleControl(position='bottomleft'))
     searchMarker = Marker(icon=AwesomeIcon(
         name="check", marker_color='green', icon_color='darkred'))
     self._m.add_control(
         SearchControl(
             position="topleft",
             url=
             'https://nominatim.openstreetmap.org/search?format=json&q={s}',
             zoom=self._zoom,
             marker=searchMarker))
Пример #5
0
    def __init__(self, **kwargs):
        """Map class
        """
        if "center" not in kwargs:
            kwargs["center"] = [40, -100]
        if "zoom" not in kwargs:
            kwargs['zoom'] = 4
        if "scroll_wheel_zoom" not in kwargs:
            kwargs["scroll_wheel_zoom"] = True

        super().__init__(**kwargs)

        if "height" not in kwargs:
            self.layout.height = "600px"
        else:
            self.layout.height = kwargs['height']

        self.add_control(FullScreenControl())
        self.add_control(LayersControl(position="bottomright"))
        self.add_control(DrawControl(position="topleft"))
        self.add_control(MeasureControl())
        self.add_control(ScaleControl(position="bottomleft"))

        main_toolbar(self)

        if "google_map" not in kwargs or kwargs["google_map"] == "ROADMAP":
            layer = TileLayer(
                url="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}",
                attribution="Google",
                name="Google Maps")
            self.add_layer(layer)
        elif kwargs["google_map"] == "HYBRID":
            layer = TileLayer(
                url="https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}",
                attribution="Google",
                name="Google Satellite")
            self.add_layer(layer)

        if 'in_csv' in kwargs:
            in_csv = kwargs['in_csv']
            x = kwargs['x']
            y = kwargs['y']
            header = kwargs['header']
            self.add_points_from_csv(in_csv, x, y, header)
Пример #6
0
        "fillOpacity": 0.5
    }
}

# display map
draw_control_map
# In[21]

import ipyleaflet
from ipyleaflet import MeasureControl

# create map
measure_control_map = ipyleaflet.Map(zoom=1)

# create control
measure = MeasureControl(position='topleft', active_color='red', primary_length_unit='miles')

# add control to map
measure_control_map.add_control(measure)

# measure line color
measure.completed_color='red'

# display map
measure_control_map

# In[22]

import ipyleaflet
from ipyleaflet import basemaps, basemap_to_tiles, SplitMapControl
Пример #7
0
    def __init__(self, **kwargs):

        if "center" not in kwargs:
            kwargs["center"] = [40, -100]

        if "zoom" not in kwargs:
            kwargs["zoom"] = 4

        if "scroll_wheel_zoom" not in kwargs:
            kwargs["scroll_wheel_zoom"] = True

        super().__init__(**kwargs)

        if "height" not in kwargs:
            self.layout.height = "600px"
        else:
            self.layout.height = kwargs["height"]

        self.add_control(FullScreenControl())
        self.add_control(LayersControl(position="topright"))
        self.add_control(DrawControl(position="topleft"))
        self.add_control(MeasureControl())
        self.add_control(ScaleControl(position="bottomleft"))
        self.toolbar = None

        # tools = {
        #     "folder-open": {
        #         "name": "open_data",
        #         "tooltip": "Open local vector/raster data"
        #     },
        #     "map": {
        #         "name": "basemap",
        #         "tooltip": "Change basemap"
        #     },
        #     "gears": {
        #         "name": "whitebox",
        #         "tooltip": "WhiteboxTools for local geoprocessing"
        #     },
        #     "filter": {
        #         "name": "query",
        #         "tooltip": "Attribute selection"
        #     },
        # }
        # icons = list(tools.keys())
        # tooltips = [item["tooltip"] for item in list(tools.values())]

        # icon_width = "32px"
        # icon_height = "32px"
        # n_cols = 3
        # n_rows = math.ceil(len(icons) / n_cols)

        # toolbar_grid = ipywidgets.GridBox(
        #     children=[
        #         ipywidgets.ToggleButton(
        #             layout=ipywidgets.Layout(
        #                 width="auto", height="auto", padding="0px 0px 0px 4px"
        #             ),
        #             button_style="primary",
        #             icon=icons[i],
        #             tooltip=tooltips[i],
        #         )
        #         for i in range(len(icons))
        #     ],
        #     layout=ipywidgets.Layout(
        #         width="107px",
        #         grid_template_columns=(icon_width + " ") * n_cols,
        #         grid_template_rows=(icon_height + " ") * n_rows,
        #         grid_gap="1px 1px",
        #         padding="5px",
        #     ),
        # )
        # self.toolbar = toolbar_grid

        if "google_map" not in kwargs:
            layer = TileLayer(
                url="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}",
                attribution="Google",
                name="Google Maps",
            )
            self.add_layer(layer)
        else:
            if kwargs["google_map"] == "ROADMAP":
                layer = TileLayer(
                    url="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}",
                    attribution="Google",
                    name="Google Maps",
                )
                self.add_layer(layer)
            elif kwargs["google_map"] == "HYBRID":
                layer = TileLayer(
                    url="https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}",
                    attribution="Google",
                    name="Google Satellite")
                self.add_layer(layer)

        if "basemap" not in kwargs:
            layer = basemap_to_tiles(basemaps.OpenStreetMap.Mapnik)
            self.add_layer(layer)
        else:
            layer = basemap_to_tiles(kwargs["basemap"])
            self.add_layer(layer)

        main_toolbar(self)