GithubHelp home page GithubHelp logo

eyeseast / datasette-geojson-map Goto Github PK

View Code? Open in Web Editor NEW
23.0 3.0 1.0 4.97 MB

Render a map for any query with a geometry column

Python 65.21% CSS 5.03% JavaScript 29.77%
geojson gis datasette-plugin leafletjs datasette-io mapping

datasette-geojson-map's People

Contributors

eyeseast avatar simonw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

simonw

datasette-geojson-map's Issues

Stamen map tiles no longer available

https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.{ext} is no longer available.

There is another deprecated url that puts up a comment rendering the map useless.
Screen Shot 2024-01-10 at 10 54 53 PM

(that other URL was: "https://tiles.stadiamaps.com/tiles/stamen_terrain/{z}/{x}/{y}{r}.{ext}") and I planned a little pull request....)

But at this point you have to create an account on https://stadiamaps.com/. And even with a free account, you are required to submit a domain name. (I didn't figure out how to use localhost. If I wanted to could probably create a hosts file but that would go beyond the scope of this README.

Is there another source of free, accessible basemaps?

UPDATE:

At the bottom of the onboarding form (where it was asking for my domain name) they had a note

Running into difficulties? Not sure what to do?
Don't panic! Our real human support is here to help.

But when I clicked the Get Help button nothing happened. Sigh. (Could be just a time-of-day issue...)
(That was on https://stadiamaps.com/stamen/onboarding/setup-authentication/ )

simplestyle query is not working for me.

Unfortunately, simplestyle isn't working for me. 
Screen Shot 2024-01-11 at 12 08 52 AM
I'm using a similar structure as the boston example. 
Screen Shot 2024-01-10 at 11 39 15 PM
  The default map does display:

Screen Shot 2024-01-10 at 11 42 16 PM

Do you have any suggestions for things I can try?

Allow switching layers

The current configuration setup assumes one tile layer:

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

What if I configured more than one layer, as an array. Then I could add a layer switch control.

datasette-geojson-map:
    tile_layers: 
        name: Stamen Terrain
        url: https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.{ext}
        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

    name: OSM
    url: https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
    options:
        attribution: &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors

broken marker images

I don't know why I'm getting broken marker images. For some reason they point to mapbox. Which is weird, because I don't see mapbox in the code. The file it's trying to access is:
https://a.tiles.mapbox.com/v3/marker/[email protected]

visiting that yields:

{
"message": "Not Authorized",
"error_detail": "Direct access not allowed"
}

I'm guessing there is some issue with leaflet.

Screen Shot 2024-01-12 at 11 28 32 PM

../-/databases

Screen Shot 2024-01-12 at 11 23 45 PM

../-/metadata

{}

../-/settings

{
    "default_page_size": 100,
    "max_returned_rows": 1000,
    "num_sql_threads": 3,
    "sql_time_limit_ms": 1000,
    "default_facet_size": 30,
    "facet_time_limit_ms": 200,
    "facet_suggest_time_limit_ms": 50,
    "allow_facet": true,
    "default_allow_sql": true,
    "allow_download": true,
    "suggest_facets": true,
    "default_cache_ttl": 5,
    "cache_size_kb": 0,
    "allow_csv_stream": true,
    "max_csv_mb": 100,
    "truncate_cells_html": 2048,
    "force_https_urls": false,
    "template_debug": false,
    "trace_debug": false,
    "base_url": "/"
}

../-/plugins

[
{
"name": "datasette-cluster-map",
"static": true,
"templates": false,
"version": "0.17.2",
"hooks": [
"extra_body_script",
"extra_js_urls"
]
},
{
"name": "datasette-enrichments",
"static": false,
"templates": true,
"version": "0.2",
"hooks": [
"actor_from_request",
"permission_allowed",
"register_routes",
"table_actions"
]
},
{
"name": "datasette-enrichments-gpt",
"static": false,
"templates": true,
"version": "0.3",
"hooks": [
"register_enrichments"
]
},
{
"name": "datasette-enrichments-jinja",
"static": false,
"templates": false,
"version": "0.1",
"hooks": [
"register_enrichments"
]
},
{
"name": "datasette-enrichments-opencage",
"static": false,
"templates": false,
"version": "0.1",
"hooks": [
"register_enrichments"
]
},
{
"name": "datasette-geojson",
"static": false,
"templates": false,
"version": "0.4.0",
"hooks": [
"prepare_connection",
"register_output_renderer"
]
},
{
"name": "datasette-geojson-map",
"static": true,
"templates": false,
"version": "0.4.0",
"hooks": [
"extra_body_script",
"extra_css_urls",
"extra_js_urls"
]
},
{
"name": "datasette-leaflet",
"static": true,
"templates": false,
"version": "0.2.2",
"hooks": [
"extra_body_script",
"extra_template_vars"
]
},
{
"name": "datasette-upload-csvs",
"static": false,
"templates": true,
"version": "0.8.3",
"hooks": [
"menu_links",
"permission_allowed",
"register_routes"
]
},
{
"name": "datasette-vega",
"static": true,
"templates": false,
"version": "0.6.2",
"hooks": [
"extra_css_urls",
"extra_js_urls"
]
}
]

Load CSS in the client, not server

This import was probably a bad idea: https://github.com/eyeseast/datasette-geojson-map/blob/main/datasette_geojson_map/__init__.py#L6

That ended up breaking with PR that changed how Leaflet URLs get generated: simonw/datasette-leaflet#9. I could run the plugin hook inside this plugin to generate the right URLs, but that still feels like the wrong way to do it. I could re-run the logic in datasette-leaflet to build the right URL, but I don't want to.

So client-side is probably the best way to ensure the right CSS and JS files are loaded.

Full screen maps

Could I add a view that generates a map on its own page? This would make maps embeddable direct from datasette. Not sure if that's really what I want to encourage, but it might be cool.

Search based on map bounds

Right now, I run a query and the map fits the bounds of the returned features. But, if I have a bounding box, I could go the other way and search features within that box. This is especially fast if I have a spatial index.

Customize popups

This isn't super useful:

Screen Shot 2022-02-22 at 8 32 10 PM

Nor is a popup with 40 rows that's too tall for the map viewport.

Feature Request: Hover inspection

I prefer the data inspection method used on mapshaper.org.

  1. The info box is available on hover
  2. The info box is located so as not to obscure the map when the field count is large.

Might be nice to have a plugin metadata option to enable these features.

Link to Boston example data is broken

In the documentation.
The link displayed in the example is wrong: wget -O neighborhoods.geojson https://opendata.arcgis.com/datasets/3525b0ee6e6b427f9aab5d0a1d0a1a28_0

How to handle API keys for map tiles?

If I want to use Mapbox tiles (and probably others) I need to pass an API key with each request. Is there a way to keep this out of version control with metadata? Or pass it as an environment variable?

It's worth noting that Mapbox is pretty explicit that access tokens aren't secret. The best case might be to use a deployment-specific token that only allows requests from a specific set of domains.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.