greppo-io / greppo

Build & deploy geospatial applications quick and easy.
https://greppo.io
Apache License 2.0
388 stars 34 forks source link

Use xyzservices in base layers #9

Closed martinfleis closed 2 years ago

martinfleis commented 2 years ago

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.

krish-adi commented 2 years ago

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.

krish-adi commented 2 years ago

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