Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Work in progress] adds custom basemap layer #490

Merged
merged 11 commits into from
Oct 19, 2018
Merged

Conversation

andy-esch
Copy link
Contributor

@andy-esch andy-esch commented Oct 15, 2018

This PR adds custom vector basemap layers to the cartoframes.contrib.vector module.

Basemaps can be CARTO VL styles or Mapbox styles (if access token is provided).

Full example:

from cartoframes.contrib import vector
from cartoframes import CartoContext, Layer
cc = CartoContext(
    base_url='https://eschbacher.carto.com',
    api_key='abc123'
)

layers = [
    vector.Layer('all_month_3'),
]
# external basemap
vector.vmap(
    layers,
    context=cc,
    basemap={
        'style': 'mapbox://styles/mapbox/streets-v9',
        'token': 'def456'
    })

# carto basemap
vector.vmap(
    layers,
    context=cc,
    basemap=vector.BaseMaps.darkmatter
)

@coveralls
Copy link

coveralls commented Oct 17, 2018

Coverage Status

Coverage decreased (-0.5%) to 96.635% when pulling 6cf627c on custom-vector-basemap into 9c9b6c6 on master.

@@ -61,7 +65,7 @@
new carto.Viz(elem['styling'])
);
var last_source = idx === 0 ? 'watername_ocean' : 'layer' + (idx - 1);
temp.addTo(map, last_source);
temp.addTo(map);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last_source needs to be returned here. The old code had:

temp.addTo(map, last_source)

There may be a better name than watername_ocean, or we should detect if it's a CARTO basemap -- and use watername_ocean if so, otherwise just plop it on the top.

@andy-esch andy-esch merged commit 957e042 into master Oct 19, 2018
@andy-esch andy-esch deleted the custom-vector-basemap branch October 19, 2018 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants