How to use the cartoframes.viz.Map function in cartoframes

To help you get started, we’ve selected a few cartoframes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CartoDB / cartoframes / test / viz / test_map.py View on Github external
def test_one_layer(self):
        """Map layer should be able to initialize one layer"""
        source = Source(build_geojson([-10, 0], [-10, 0]))
        layer = Layer(source)
        map = Map(layer)

        self.assertEqual(map.layers, [layer])
        self.assertEqual(len(map.sources), 1)
        self.assertEqual(map.sources[0].get('interactivity'), [])
        self.assertIsNotNone(map.sources[0].get('credentials'))
        self.assertIsNone(map.sources[0].get('legend'))
        self.assertIsNotNone(map.sources[0].get('query'))
        self.assertEqual(map.sources[0].get('type'), 'GeoJSON')
        self.assertIsNotNone(map.sources[0].get('viz'))
github CartoDB / cartoframes / tests / unit / viz / test_map.py View on Github external
def test_custom_airship_path(self):
        """Map dev path should use custom paths"""
        _airship_path = 'custom_airship_path'
        map = Map(_airship_path=_airship_path)
        map._repr_html_()
        template = map._html_map.html
        assert _airship_path + constants.AIRSHIP_COMPONENTS_DEV in template
        assert _airship_path + constants.AIRSHIP_BRIDGE_DEV in template
        assert _airship_path + constants.AIRSHIP_STYLES_DEV in template
        assert _airship_path + constants.AIRSHIP_MODULE_DEV in template
        assert _airship_path + constants.AIRSHIP_ICONS_DEV in template
github CartoDB / cartoframes / test / viz / test_map.py View on Github external
def test_custom_carto_vl_path(self):
        """Map dev path should use custom paths"""
        _carto_vl_path = 'custom_carto_vl_path'
        map = Map(_carto_vl_path=_carto_vl_path)
        map._repr_html_()
        template = map._htmlMap.html
        self.assertTrue(_carto_vl_path + constants.CARTO_VL_DEV in template)
github CartoDB / cartoframes / test / viz / test_kuviz.py View on Github external
def test_kuviz_publisher_create_remote(self):
        dataset = DatasetMock('fake_table', credentials=self.credentials)
        vmap = Map(Layer(Source(dataset)))

        kp = KuvizPublisherMock(vmap.layers)
        self.assertNotEqual(kp._layers, vmap.layers)
        self.assertEqual(len(kp._layers), len(vmap.layers))
github CartoDB / cartoframes / test / viz / test_kuviz.py View on Github external
def test_kuviz_publisher_sync_layers(self):
        dataset = DatasetMock(build_geojson([-10, 0], [-10, 0]))
        vmap = Map(Layer(Source(dataset)))

        kp = KuvizPublisherMock(vmap.layers)
        kp.sync_layers(table_name='fake_table', credentials=self.credentials)
        self.assertEqual(kp.is_sync(), True)
github CartoDB / cartoframes / tests / unit / viz / test_kuviz.py View on Github external
def test_kuviz_publisher_update(self, mocker):
        setup_mocks(mocker, self.credentials)

        kuviz = CartoKuvizMock('fake_kuviz')
        mocker.patch('cartoframes.viz.kuviz._create_kuviz', return_value=kuviz)

        vmap = Map(Layer('fake_table', credentials=self.credentials))

        html = 'fake_html'
        kuviz_name = 'fake_name'

        kuviz_publisher = KuvizPublisher(None)
        kuviz_publisher.set_layers(vmap.layers, kuviz_name, 'fake_table_name')
        result_publish = kuviz_publisher.publish(html, kuviz_name, None)

        kuviz.name = 'fake_name_2'
        result_update = kuviz_publisher.update(html, kuviz_name, None)

        assert kuviz_publisher.kuviz == kuviz
        assert result_update == kuviz_to_dict(kuviz)
        assert result_publish != kuviz_to_dict(kuviz)
github CartoDB / cartoframes / tests / unit / viz / test_kuviz.py View on Github external
def test_kuviz_publisher_has_layers_copy(self, mocker):
        setup_mocks(mocker, self.credentials)

        source_1 = Source('fake_table_2', credentials=self.credentials)
        layer_1 = Layer(source_1)
        vmap = Map([layer_1])

        kuviz_publisher = KuvizPublisher(None)
        kuviz_publisher.set_layers(vmap.layers, 'fake_name', 'fake_table_name')

        assert len(kuviz_publisher._layers) == len(vmap.layers)
        assert kuviz_publisher._layers == vmap.layers

        vmap.layers = []
        assert len(kuviz_publisher._layers) != len(vmap.layers)
        assert len(kuviz_publisher._layers) > 0
github CartoDB / cartoframes / test / viz / test_map.py View on Github external
def test_custom_airship_path(self):
        """Map dev path should use custom paths"""
        _airship_path = 'custom_airship_path'
        map = Map(_airship_path=_airship_path)
        map._repr_html_()
        template = map._htmlMap.html
        self.assertTrue(_airship_path + constants.AIRSHIP_COMPONENTS_DEV in template)
        self.assertTrue(_airship_path + constants.AIRSHIP_BRIDGE_DEV in template)
        self.assertTrue(_airship_path + constants.AIRSHIP_STYLES_DEV in template)
        self.assertTrue(_airship_path + constants.AIRSHIP_MODULE_DEV in template)
        self.assertTrue(_airship_path + constants.AIRSHIP_ICONS_DEV in template)
github CartoDB / cartoframes / tests / unit / viz / test_map.py View on Github external
def test_map_publish_update_password(self, mocker):
        setup_mocks(mocker)

        map = Map(Layer(Source('fake_table', credentials=self.credentials)))

        name = 'cf_publish'
        map.publish(name, None, credentials=self.credentials)
        kuviz_dict = map.update_publication(name, '1234"')

        self.assert_kuviz_dict(kuviz_dict, name, 'password')
github CartoDB / cartoframes / cartoframes / data / carto_data_frame.py View on Github external
def map(self, *args, ** kwargs):
        """Renders the data in a CARTO map.

         Returns:
            :py:class:`Map `
        """
        from ..viz import Map, Layer
        return Map(Layer(self, *args, **kwargs))