Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def render(self, resp: requests.models.Response) -> ipyleaflet.Map:
"Return an ipyleaflet map with the GeoJSON object rendered on it, or None."
obj = resp.json()
if obj.get('type', None) != 'FeatureCollection':
return None
bbox = geojson_bbox(obj)
mins, maxs = bbox
center = list(reversed(bbox_center(*bbox)))
z = zoom_for_bbox(*(mins + maxs))
m = ipyleaflet.Map(center=center, zoom=z + 1)
m.add_layer(layer=ipyleaflet.GeoJSON(data=obj))
self.data = m
return m
:type inspect: dict
:return: the name of the added layer
:rtype: str
"""
thename = name if name else 'Geometry {}'.format(self.addedGeometries)
# Check if layer exists
if thename in self.EELayers.keys():
if not replace:
print("Layer with name '{}' exists already, please choose another name".format(thename))
return
else:
self.removeLayer(thename)
params = getGeojsonTile(geometry, thename, inspect)
layer = ipyleaflet.GeoJSON(data=params['geojson'],
name=thename,
popup=HTML(params['pop']))
self._add_EELayer(thename, {'type': 'Geometry',
'object': geometry,
'visParams':None,
'layer': layer})
return thename
:type inspect: dict
:return: the name of the added layer
:rtype: str
"""
thename = name if name else 'Geometry {}'.format(self.addedGeometries)
# Check if layer exists
if thename in self.EELayers.keys():
if not replace:
print("Layer with name '{}' exists already, please choose another name".format(thename))
return
else:
self.removeLayer(thename)
params = getGeojsonTile(geometry, thename, inspect)
layer = ipyleaflet.GeoJSON(data=params['geojson'],
name=thename,
popup=HTML(params['pop']))
self._add_EELayer(thename, {'type': 'Geometry',
'object': geometry,
'visParams':None,
'layer': layer})
return thename
:type inspect: dict
:return: the name of the added layer
:rtype: str
"""
thename = name if name else 'Feature {}'.format(self.addedGeometries)
# Check if layer exists
if thename in self.EELayers.keys():
if not replace:
print("Layer with name '{}' exists already, please choose another name".format(thename))
return
else:
self.removeLayer(thename)
params = getGeojsonTile(feature, thename, inspect)
layer = ipyleaflet.GeoJSON(data=params['geojson'],
name=thename,
popup=HTML(params['pop']))
self._add_EELayer(thename, {'type': 'Feature',
'object': feature,
'visParams': None,
'layer': layer})
return thename
:type inspect: dict
:return: the name of the added layer
:rtype: str
"""
thename = name if name else 'Feature {}'.format(self.addedGeometries)
# Check if layer exists
if thename in self.EELayers.keys():
if not replace:
print("Layer with name '{}' exists already, please choose another name".format(thename))
return
else:
self.removeLayer(thename)
params = getGeojsonTile(feature, thename, inspect)
layer = ipyleaflet.GeoJSON(data=params['geojson'],
name=thename,
popup=HTML(params['pop']))
self._add_EELayer(thename, {'type': 'Feature',
'object': feature,
'visParams': None,
'layer': layer})
return thename