def __init__(self, location=None, width='100%', height='100%', left='0%', top='0%', position='relative', tiles='OpenStreetMap', API_key=None, max_zoom=18, min_zoom=0, max_native_zoom=None, zoom_start=10, world_copy_jump=False, no_wrap=False, attr=None, min_lat=-90, max_lat=90, min_lon=-180, max_lon=180, max_bounds=False, detect_retina=False, crs='EPSG3857', control_scale=False, prefer_canvas=False, no_touch=False, disable_3d=False, subdomains='abc', png_enabled=False, zoom_control=True): super(Map, self).__init__() self._name = 'Map' self._env = ENV # Undocumented for now b/c this will be subject to a re-factor soon. self._png_image = None self.png_enabled = png_enabled if not location: # If location is not passed we center and zoom out. self.location = [0, 0] self.zoom_start = 1 else: self.location = _validate_location(location) self.zoom_start = zoom_start Figure().add_child(self) # Map Size Parameters. self.width = _parse_size(width) self.height = _parse_size(height) self.left = _parse_size(left) self.top = _parse_size(top) self.position = position self.min_lat = min_lat self.max_lat = max_lat self.min_lon = min_lon self.max_lon = max_lon self.max_bounds = max_bounds self.no_wrap = no_wrap self.world_copy_jump = world_copy_jump self.crs = crs self.control_scale = control_scale self.zoom_control = zoom_control self.global_switches = GlobalSwitches( prefer_canvas, no_touch, disable_3d ) self.objects_to_stay_in_front = [] if tiles: self.add_tile_layer( tiles=tiles, min_zoom=min_zoom, max_zoom=max_zoom, max_native_zoom=max_native_zoom, no_wrap=no_wrap, attr=attr, API_key=API_key, detect_retina=detect_retina, subdomains=subdomains )
def __init__(self, location, popup=None, icon=None, heading=0, wind_heading=None, wind_speed=0, **kwargs): super(BoatMarker, self).__init__(_validate_location(location), popup=popup, icon=icon) self._name = 'BoatMarker' self.heading = heading self.wind_heading = wind_heading self.wind_speed = wind_speed self.kwargs = json.dumps(kwargs) self._template = Template(u""" {% macro script(this, kwargs) %} var {{this.get_name()}} = L.boatMarker( [{{this.location[0]}},{{this.location[1]}}], {{this.kwargs}}).addTo({{this._parent.get_name()}}); {{this.get_name()}}.setHeadingWind({{this.heading}}, {{this.wind_speed}}, {{this.wind_heading}}); {% endmacro %} """) # noqa
def __init__(self, location, radius=500, color='black', fill_color='black', fill_opacity=0.6, popup=None): super(Circle, self).__init__( _validate_location(location), popup=popup ) self._name = 'Circle' self.radius = radius self.color = color self.fill_color = fill_color self.fill_opacity = fill_opacity self._template = Template(u""" {% macro script(this, kwargs) %} var {{this.get_name()}} = L.circle( [{{this.location[0]}},{{this.location[1]}}], {{ this.radius }}, { color: '{{ this.color }}', fillColor: '{{ this.fill_color }}', fillOpacity: {{ this.fill_opacity }} } ) .addTo({{this._parent.get_name()}}); {% endmacro %} """)
def __init__(self, location=None, width='100%', height='100%', left='0%', top='0%', position='relative', tiles='OpenStreetMap', API_key=None, max_zoom=18, min_zoom=0, max_native_zoom=None, zoom_start=10, world_copy_jump=False, no_wrap=False, attr=None, min_lat=-90, max_lat=90, min_lon=-180, max_lon=180, max_bounds=False, detect_retina=False, crs='EPSG3857', control_scale=False, prefer_canvas=False, no_touch=False, disable_3d=False, subdomains='abc', png_enabled=False, zoom_control=True): super(Map, self).__init__() self._name = 'Map' self._env = ENV # Undocumented for now b/c this will be subject to a re-factor soon. self._png_image = None self.png_enabled = png_enabled if location is None: # If location is not passed we center and zoom out. self.location = [0, 0] self.zoom_start = 1 else: self.location = _validate_location(location) self.zoom_start = zoom_start Figure().add_child(self) # Map Size Parameters. self.width = _parse_size(width) self.height = _parse_size(height) self.left = _parse_size(left) self.top = _parse_size(top) self.position = position self.min_lat = min_lat self.max_lat = max_lat self.min_lon = min_lon self.max_lon = max_lon self.max_bounds = max_bounds self.no_wrap = no_wrap self.world_copy_jump = world_copy_jump self.crs = crs self.control_scale = control_scale self.zoom_control = zoom_control self.global_switches = GlobalSwitches( prefer_canvas, no_touch, disable_3d ) self.objects_to_stay_in_front = [] if tiles: self.add_tile_layer( tiles=tiles, min_zoom=min_zoom, max_zoom=max_zoom, max_native_zoom=max_native_zoom, no_wrap=no_wrap, attr=attr, API_key=API_key, detect_retina=detect_retina, subdomains=subdomains )
def __init__(self, location, popup=None, icon=None, heading=0, wind_heading=None, wind_speed=0, **kwargs): super(BoatMarker, self).__init__(_validate_location(location), popup=popup, icon=icon) self._name = 'BoatMarker' self.heading = heading self.wind_heading = wind_heading self.wind_speed = wind_speed self.kwargs = json.dumps(kwargs)
def __init__(self, location, radius=10, popup=None, **kw): super(Circle, self).__init__(_validate_location(location), popup=popup) self._name = 'circle' options = _parse_path(**kw) options.update({'radius': radius}) self.options = json.dumps(options, sort_keys=True, indent=2) self._template = Template(u""" {% macro script(this, kwargs) %} var {{this.get_name()}} = L.circle( [{{this.location[0]}},{{this.location[1]}}], {{ this.options }} ).addTo({{this._parent.get_name()}}); {% endmacro %} """)
def __init__(self, location, radius=0, direction=0, arc=0, startAngle=0, stopAngle=0, **kwargs): super(SemiCircle, self).__init__(_validate_location(location), **kwargs) self._name = 'SemiCircle' self.radius = radius self.direction = direction self.arc = arc self.startAngle = startAngle self.stopAngle = stopAngle self.kwargs = json.dumps(kwargs)
def __init__(self, location, popup=None, icon=None, heading=0, wind_heading=None, wind_speed=0, **kwargs): super(BoatMarker, self).__init__( _validate_location(location), popup=popup, icon=icon ) self._name = 'BoatMarker' self.heading = heading self.wind_heading = wind_heading self.wind_speed = wind_speed self.kwargs = json.dumps(kwargs) self._template = Template(u""" {% macro script(this, kwargs) %} var {{this.get_name()}} = L.boatMarker( [{{this.location[0]}},{{this.location[1]}}], {{this.kwargs}}).addTo({{this._parent.get_name()}}); {{this.get_name()}}.setHeadingWind({{this.heading}}, {{this.wind_speed}}, {{this.wind_heading}}); {% endmacro %} """) # noqa
def __init__(self, location=None, width='100%', height='100%', left='0%', top='0%', position='relative', tiles='OpenStreetMap', API_key=None, max_zoom=18, min_zoom=1, zoom_start=10, continuous_world=False, world_copy_jump=False, no_wrap=False, attr=None, min_lat=-90, max_lat=90, min_lon=-180, max_lon=180, max_bounds=False, detect_retina=False, crs='EPSG3857', control_scale=False, prefer_canvas=False, no_touch=False, disable_3d=False, subdomains='abc', png_enabled=False): super(LegacyMap, self).__init__() self._name = 'Map' self._env = ENV # Undocumented for now b/c this will be subject to a re-factor soon. self._png_image = None self.png_enabled = png_enabled if not location: # If location is not passed we center and ignore zoom. self.location = [0, 0] self.zoom_start = min_zoom else: self.location = _validate_location(location) self.zoom_start = zoom_start Figure().add_child(self) # Map Size Parameters. self.width = _parse_size(width) self.height = _parse_size(height) self.left = _parse_size(left) self.top = _parse_size(top) self.position = position self.min_lat = min_lat self.max_lat = max_lat self.min_lon = min_lon self.max_lon = max_lon self.max_bounds = max_bounds self.continuous_world = continuous_world self.no_wrap = no_wrap self.world_copy_jump = world_copy_jump self.crs = crs self.control_scale = control_scale self.global_switches = GlobalSwitches(prefer_canvas, no_touch, disable_3d) if tiles: self.add_tile_layer(tiles=tiles, min_zoom=min_zoom, max_zoom=max_zoom, continuous_world=continuous_world, no_wrap=no_wrap, attr=attr, API_key=API_key, detect_retina=detect_retina, subdomains=subdomains) self._template = Template(u""" {% macro header(this, kwargs) %} <style> #{{this.get_name()}} { position : {{this.position}}; width : {{this.width[0]}}{{this.width[1]}}; height: {{this.height[0]}}{{this.height[1]}}; left: {{this.left[0]}}{{this.left[1]}}; top: {{this.top[0]}}{{this.top[1]}}; } </style> {% endmacro %} {% macro html(this, kwargs) %} <div class="folium-map" id="{{this.get_name()}}" ></div> {% endmacro %} {% macro script(this, kwargs) %} {% if this.max_bounds %} var southWest = L.latLng({{ this.min_lat }}, {{ this.min_lon }}); var northEast = L.latLng({{ this.max_lat }}, {{ this.max_lon }}); var bounds = L.latLngBounds(southWest, northEast); {% else %} var bounds = null; {% endif %} var {{this.get_name()}} = L.map( '{{this.get_name()}}', {center: [{{this.location[0]}},{{this.location[1]}}], zoom: {{this.zoom_start}}, maxBounds: bounds, layers: [], worldCopyJump: {{this.world_copy_jump.__str__().lower()}}, crs: L.CRS.{{this.crs}} }); {% if this.control_scale %}L.control.scale().addTo({{this.get_name()}});{% endif %} {% endmacro %} """) # noqa
def __init__(self, location=None, width='100%', height='100%', left='0%', top='0%', position='relative', tiles='OpenStreetMap', API_key=None, max_zoom=18, min_zoom=0, max_native_zoom=None, zoom_start=10, world_copy_jump=False, no_wrap=False, attr=None, min_lat=-90, max_lat=90, min_lon=-180, max_lon=180, max_bounds=False, detect_retina=False, crs='EPSG3857', control_scale=False, prefer_canvas=False, no_touch=False, disable_3d=False, subdomains='abc', png_enabled=False): super(Map, self).__init__() self._name = 'Map' self._env = ENV # Undocumented for now b/c this will be subject to a re-factor soon. self._png_image = None self.png_enabled = png_enabled if not location: # If location is not passed we center and zoom out. self.location = [0, 0] self.zoom_start = 1 else: self.location = _validate_location(location) self.zoom_start = zoom_start Figure().add_child(self) # Map Size Parameters. self.width = _parse_size(width) self.height = _parse_size(height) self.left = _parse_size(left) self.top = _parse_size(top) self.position = position self.min_lat = min_lat self.max_lat = max_lat self.min_lon = min_lon self.max_lon = max_lon self.max_bounds = max_bounds self.no_wrap = no_wrap self.world_copy_jump = world_copy_jump self.crs = crs self.control_scale = control_scale self.global_switches = GlobalSwitches( prefer_canvas, no_touch, disable_3d ) if tiles: self.add_tile_layer( tiles=tiles, min_zoom=min_zoom, max_zoom=max_zoom, max_native_zoom=max_native_zoom, no_wrap=no_wrap, attr=attr, API_key=API_key, detect_retina=detect_retina, subdomains=subdomains ) self._template = Template(u""" {% macro header(this, kwargs) %} <style> #{{this.get_name()}} { position : {{this.position}}; width : {{this.width[0]}}{{this.width[1]}}; height: {{this.height[0]}}{{this.height[1]}}; left: {{this.left[0]}}{{this.left[1]}}; top: {{this.top[0]}}{{this.top[1]}}; } </style> {% endmacro %} {% macro html(this, kwargs) %} <div class="folium-map" id="{{this.get_name()}}" ></div> {% endmacro %} {% macro script(this, kwargs) %} {% if this.max_bounds %} var southWest = L.latLng({{ this.min_lat }}, {{ this.min_lon }}); var northEast = L.latLng({{ this.max_lat }}, {{ this.max_lon }}); var bounds = L.latLngBounds(southWest, northEast); {% else %} var bounds = null; {% endif %} var {{this.get_name()}} = L.map( '{{this.get_name()}}', {center: [{{this.location[0]}},{{this.location[1]}}], zoom: {{this.zoom_start}}, maxBounds: bounds, layers: [], worldCopyJump: {{this.world_copy_jump.__str__().lower()}}, crs: L.CRS.{{this.crs}} }); {% if this.control_scale %}L.control.scale().addTo({{this.get_name()}});{% endif %} {% endmacro %} """) # noqa