Skip to content

Commit

Permalink
Merge pull request #6 from jtmiclat/chore/update-readme
Browse files Browse the repository at this point in the history
Add recommended way of using the library in README
  • Loading branch information
jtmiclat authored Sep 22, 2023
2 parents 9d197fd + 17e7643 commit 286b7d9
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,53 @@
```
pip install folium folium-pmtiles
```

### Usage
See [example/](example/) to see some examples.

The recommend way is to use `PMTilesMapLibreLayer`. This overlays a maplibre instance over leaflet which allows declarative styling using mapbox style specification.

A simple folium example is as follows:

```python
import folium

from folium_pmtiles.vector import PMTilesMapLibreLayer

m = folium.Map(location=[43.7798, 11.24148], zoom_start=13, tiles="cartodb positron")
pmtiles_url = "https://pmtiles.jtmiclat.me/protomaps(vector)ODbL_firenze.pmtiles"
pmtiles_layer = PMTilesMapLibreLayer(
"folium_layer_name",
style={
"version": 8,
"sources": {
"example_source": {
"type": "vector",
"url": "pmtiles://" + pmtiles_url,
"attribution": '<a href="https://protomaps.com">Protomaps</a> © <a href="https://openstreetmap.org/copyright">OpenStreetMap</a>',
}
},
"layers": [
{
"id": "buildings",
"source": "example_source",
"source-layer": "landuse",
"type": "fill",
"paint": {"fill-color": "steelblue"},
},
{
"id": "roads",
"source": "example_source",
"source-layer": "roads",
"type": "line",
"paint": {"line-color": "black"},
},
],
},
)
m.add_child(pmtiles_layer)
```

See [example/](example/) to see more examples and live demos via google collab or github.dev.

## Dev Setup

Expand Down

0 comments on commit 286b7d9

Please sign in to comment.