from operator import attrgetter
import random
import datetime

import dash
from dash.dependencies import Input, Output, State
from dash import html
# import dash_core_components as dcc
import dash_leaflet as dl

import dash_geoman as dgm


external_stylesheets=[

]


app = dash.Dash(
    __name__,
    external_stylesheets=external_stylesheets,
    suppress_callback_exceptions=True
)
app.scripts.config.serve_locally = True
app.css.config.serve_locally = True

app.layout = html.Div([
    dl.Map(id='map', center=(64.79591, 30.679537), zoom=4, children=[

        dl.LayersControl(children=[
            dl.BaseLayer(dl.TileLayer(), name='OpenStreetMap', checked=True)
        ]),
        # dgm.Geoman2(),
        dgm.Geoman(),
        dl.MeasureControl(),
        # dgm.MeasureControl(),
        # dgm.EditControl(),
    ], style=dict(width='100%', height='100%'))
], style=dict(width='99%', height='99%', position='absolute'))

# @app.callback(Output('div_ddb', 'children'), Input('ddb', 'selectedItemKey'), prevent_initial_call=True)
# def ddb(selectedItemKey):
#     print('ddb selectedItemKey', selectedItemKey)
#     return dash.no_update


if __name__ == '__main__':
    app.run_server(debug=True)
