Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from ipywidgets import Layout, IntRangeSlider, ColorPicker, IntSlider, FloatSlider
import ipywidgets as widgets
import pandas as pd
import geojson
import os
import math
from .._version import EXTENSION_VERSION
class HeatLayer(Layer):
_view_name = Unicode("SuperMapHeatLayerView").tag(sync=True)
_model_name = Unicode("SuperMapHeatLayerModel").tag(sync=True)
_view_module = Unicode("iclientpy").tag(sync=True)
_model_module = Unicode("iclientpy").tag(sync=True)
_view_module_version = Unicode(EXTENSION_VERSION).tag(sync=True)
_model_module_version = Unicode(EXTENSION_VERSION).tag(sync=True)
heat_points = List([]).tag(sync=True)
@validate('heat_points')
def _validate_heat_points(self, proposal):
if (proposal['value'] is None):
raise Exception("error data")
self.max = max(dt[2] for dt in self.heat_points)
return proposal['value']
radius = Int(25).tag(sync=True, o=True)
min_opacity = Float(0.05).tag(sync=True, o=True)
max_zoom = Int().tag(sync=True, o=True)
max = Float(1.0).tag(sync=True, o=True)
blur = Int(15).tag(sync=True, o=True)
gradient = Dict().tag(sync=True, o=True)
def __init__(self, name, data, **kwargs):
super(RankSymbolThemeLayer, self).__init__(**kwargs)
self.name = name
self.sdata = data
class MapView(Map):
@default('layout')
def _default_layout(self):
return Layout(height='500px', align_self='stretch')
_view_name = Unicode("SuperMapMapView").tag(sync=True)
_model_name = Unicode("SuperMapMapModel").tag(sync=True)
_view_module = Unicode("iclientpy").tag(sync=True)
_model_module = Unicode("iclientpy").tag(sync=True)
_view_module_version = Unicode(EXTENSION_VERSION).tag(sync=True)
_model_module_version = Unicode(EXTENSION_VERSION).tag(sync=True)
center = List([34.5393842300, 108.9282514100]).tag(sync=True, o=True)
zoom = Int(15).tag(sync=True, o=True)
crs = Unicode('EPSG3857').tag(sync=True, o=True)
prefer_canvas = Bool(False).tag(sync=True, o=True)
@default('default_tiles')
def _default_tiles(self):
return CloudTileLayer()
def load_geojson_data():
with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "chinageojson.json"), 'r',
encoding='utf-8') as geoJsonFile:
return geojson.load(geoJsonFile)
from traitlets import Instance
from traitlets import validate
from traitlets import Float
from ._version import EXTENSION_VERSION
class Layer(Widget):
"""
:type _map: Map
"""
_view_name = Unicode("SuperMapLayerView").tag(sync=True)
_model_name = Unicode("SuperMapLayerModel").tag(sync=True)
_view_module = Unicode("iclientpy").tag(sync=True)
_model_module = Unicode("iclientpy").tag(sync=True)
_view_module_version = Unicode(EXTENSION_VERSION).tag(sync=True)
_model_module_version = Unicode(EXTENSION_VERSION).tag(sync=True)
_map = None
options = List(trait=Unicode).tag(sync=True)
@default("options")
def _default_options(self):
return [name for name in self.traits(o=True)]
visibility = Bool(False).tag(sync=True)
@observe('visibility')
def _update_visibility(self, change):
old = change['old']
new = change['new']
if self._map is None:
raise Exception("no map")
def remove_markers(self):
self.markers = ()
# @register
class Map(DOMWidget):
@default('layout')
def _default_layout(self):
return Layout(height='400px', align_self='stretch')
_view_name = Unicode('SuperMapMapView').tag(sync=True)
_model_name = Unicode('SuperMapMapModel').tag(sync=True)
_view_module = Unicode('iclientpy').tag(sync=True)
_model_module = Unicode('iclientpy').tag(sync=True)
_view_module_version = Unicode(EXTENSION_VERSION).tag(sync=True)
_model_module_version = Unicode(EXTENSION_VERSION).tag(sync=True)
# center = List(trait=Float).tag(sync=True)
layers = Tuple(trait=Instance(Layer)).tag(sync=True, **widget_serialization)
layer_ids = List()
@validate('layers')
def _validate_layers(self, proposal):
self.layer_ids = [l.model_id for l in proposal['value']]
# if len(set(self.layer_ids) != len(self.layer_ids)):
# raise Exception('duplicate layer detected')
return proposal['value']
def add_layer(self, layer):
"""
:type layer:Layer