예제 #1
0
파일: folium.py 프로젝트: zewdu94/folium
    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
            )
예제 #2
0
파일: folium.py 프로젝트: lipiss/djangoTest
    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
            )
예제 #3
0
    def __init__(self, data, width=None, height=None,
                 left='0%', top='0%', position='relative'):
        super(VegaLite, self).__init__()
        self._name = 'VegaLite'
        self.data = data.to_json() if hasattr(data, 'to_json') else data
        if isinstance(self.data, text_type) or isinstance(data, binary_type):
            self.data = json.loads(self.data)

        # Size Parameters.
        self.width = _parse_size(self.data.get('width', '100%') if
                                 width is None else width)
        self.height = _parse_size(self.data.get('height', '100%') if
                                  height is None else height)
        self.left = _parse_size(left)
        self.top = _parse_size(top)
        self.position = position
예제 #4
0
파일: features.py 프로젝트: zewdu94/folium
    def __init__(self, data, width=None, height=None,
                 left='0%', top='0%', position='relative'):
        super(VegaLite, self).__init__()
        self._name = 'VegaLite'
        self.data = data.to_json() if hasattr(data, 'to_json') else data
        if isinstance(self.data, text_type) or isinstance(data, binary_type):
            self.data = json.loads(self.data)

        # Size Parameters.
        self.width = _parse_size(self.data.get('width', '100%') if
                                 width is None else width)
        self.height = _parse_size(self.data.get('height', '100%') if
                                  height is None else height)
        self.left = _parse_size(left)
        self.top = _parse_size(top)
        self.position = position
예제 #5
0
파일: map.py 프로젝트: mojones/folium
    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, attr=None, min_lat=-90, max_lat=90,
                 min_lon=-180, max_lon=180, detect_retina=False,
                 crs='EPSG3857', control_scale=False):
        super(LegacyMap, self).__init__()
        self._name = 'Map'
        self._env = ENV

        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 = location
            self.zoom_start = zoom_start

        Figure().add_children(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.crs = crs
        self.control_scale = control_scale

        if tiles:
            self.add_tile_layer(tiles=tiles, min_zoom=min_zoom, max_zoom=max_zoom,
                                attr=attr, API_key=API_key,
                                detect_retina=detect_retina)

        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) %}

            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);

            var {{this.get_name()}} = L.map('{{this.get_name()}}', {
                                           center:[{{this.location[0]}},{{this.location[1]}}],
                                           zoom: {{this.zoom_start}},
                                           maxBounds: bounds,
                                           layers: [],
                                           crs: L.CRS.{{this.crs}}
                                         });
            {% if this.control_scale %}L.control.scale().addTo({{this.get_name()}});{% endif %}
        {% endmacro %}
        """)
예제 #6
0
파일: map.py 프로젝트: rsignell-usgs/folium
    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=True,
                 detect_retina=False,
                 crs='EPSG3857',
                 control_scale=False,
                 prefer_canvas=False,
                 no_touch=False,
                 disable_3d=False):
        super(LegacyMap, self).__init__()
        self._name = 'Map'
        self._env = ENV

        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 = 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)

        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
예제 #7
0
파일: map.py 프로젝트: shankari/folium
    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=True,
        detect_retina=False,
        crs="EPSG3857",
        control_scale=False,
        prefer_canvas=False,
        no_touch=False,
        disable_3d=False,
    ):
        super(LegacyMap, self).__init__()
        self._name = "Map"
        self._env = ENV

        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 = 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,
            )

        self._template = Template(
            """
        {% 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
예제 #8
0
    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