Skip to content

Commit

Permalink
v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Jul 7, 2021
1 parent 517b875 commit 7627f9e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ For example, you might use [geojson-to-sqlite](https://pypi.org/project/geojson-

```sh
wget -O neighborhoods.geojson https://opendata.arcgis.com/datasets/3525b0ee6e6b427f9aab5d0a1d0a1a28_0.geojson
geojson-to-sqlite boston.db neighborhoods neighborhoods.geojson --spatial-index # create a spatial index
geojson-to-sqlite boston.db neighborhoods neighborhoods.geojson
```

(The command above uses Spatialite, but that's not required.)

Start up `datasette` and navigate to the `neighborhoods` table.

```sh
datasette serve boston.db --load-extension spatialite
datasette serve boston.db

# in another terminal tab
open http://localhost:8001/boston/neighborhoods
Expand All @@ -41,6 +41,33 @@ You should see a map centered on Boston with each neighborhood outlined. Clickin

This plugin relies on (and will install) [datasette-geojson](https://github.com/eyeseast/datasette-geojson). Any query that includes a `geometry` column will produce a map of the results. This also includes single row views.

Run the included `demo` project to see it live.

## Configuration

This project uses the same map configuration as [datasette-cluster-map](https://github.com/simonw/datasette-cluster-map). Here's how you would use [Stamen's terrain tiles](http://maps.stamen.com/terrain/#12/37.7706/-122.3782):

```yaml
plugins:
datasette-geojson-map:
tile_layer: https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.{ext}
tile_layer_options:
attribution: >-
Map tiles by <a href="http://stamen.com">Stamen Design</a>,
under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>.
Data by <a href="http://openstreetmap.org">OpenStreetMap</a>,
under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.
subdomains: abcd
minZoom: 1
maxZoom: 16
ext: jpg
```
Options:
- `tile_layer`: Use a URL template that can be passed to a [Leaflet Tilelayer](https://leafletjs.com/reference-1.7.1.html#tilelayer)
- `tile_layer_options`: All options will be passed to the tile layer. See [Leaflet documentation](https://leafletjs.com/reference-1.7.1.html#tilelayer) for more on possible values here.

## Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:
Expand Down
9 changes: 5 additions & 4 deletions demo/metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ plugins:
tile_layer: https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.{ext}
tile_layer_options:
attribution: >-
Map tiles by <a href=\"http://stamen.com\">Stamen Design</a>,
<a href=\"http://creativecommons.org/licenses/by/3.0\">CC BY 3.0</a> &mdash; Map data &copy;
<a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors
Map tiles by <a href="http://stamen.com">Stamen Design</a>,
under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>.
Data by <a href="http://openstreetmap.org">OpenStreetMap</a>,
under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.
subdomains: abcd
minZoom: 1
maxZoom: 16
ext: "jpg"
ext: jpg
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup
import os

VERSION = "0.2.1"
VERSION = "0.3.0"


def get_long_description():
Expand Down

0 comments on commit 7627f9e

Please sign in to comment.