greppo-io/greppo

Use xyzservices in base layers

martinfleis opened this issue · 2 comments

As far a I can tell, a user needs to specify all details of a base layer when adding it to app.

from greppo import app

app.base_layer(
    name="CartoDB Light",
    visible=True,
    url="https://cartodb-basemaps-a.global.ssl.fastly.net/light_all/{z}/{x}/{y}@2x.png",
    subdomains=None,
    attribution='&copy; <a target="_blank" href="http://osm.org/copyright">OpenStreetMap</a> contributors',
)

You can make this easier if you make this dependent on the xyzservices package we have built for geopandas and contextily. It has all these info, so you could do something like

from greppo import app
import xyzservices.providers as xyz

app.base_layer(
    xyz.CartoDB.Positron,
    visible=True,
)

Or you can use its query_name method under the hood and simplify it to

from greppo import app

app.base_layer(
    name="CartoDB Positron",
    visible=True,
)

Happy to help with that if you need.

That makes sense. Asking the user for a provider would make it quicker.

from greppo import app
import xyzservices.providers as xyz

app.base_layer(
    provider='CartoDB Positron',
    visible=True,
)

I'll put together the new API for the next release.

@martinfleis base_layer now takes a provider to support xyzservices. I'll soon publish a blog post on this. Nice work with xyzservices.