Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Update interactive map preview #176

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@

## 0.10.0 (in development)

- now requires Go 1.18+.
- supports GCC11 on Ubuntu 22.04 (#166)
- switch from Docker Hub to Github Container Registry (#168)

### Breaking changes

- now requires Go 1.18+.
- replaced Leaflet and Mapbox GL JS maps used in preview endpoint with MapLibre GL.
This change drops the interactive map controls present in the Leaflet preview
(opacity slider, basemap changer, zoombox) (#176).
- removed built-in basemaps used in the preview endpoint (#176). You can now
specify a basemap style using the `--basemap-style-url` option or basemap
image tiles using the `--basemap-tiles-url` option.

## 0.9.0

### Breaking changes
Expand Down
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,42 @@ returns something like this:

`mbtileserver` automatically creates a map preview page for each tileset at `/services/<tileset_id>/map`.

This currently uses `Leaflet` for image tiles and `Mapbox GL JS` for vector tiles.
It uses `MapLibre GL` to render vector and image tiles.

No built-in basemap is included by default in the map preview. You can use
one of the following options to include a basemap.

### Basemap style URL

To include a [MapLibre GL style URL](https://maplibre.org/maplibre-style-spec/)
use the `--basemap-style-url` option to provide a URL to that style:

```
--basemap-style-url "https://tiles.stadiamaps.com/styles/stamen_toner_lite.json?api_key=<your key>
```

The URL can include query parameters as required by the host, such as
`?access_token=<something>`.


### Basemap tiles URL

To include a basemap based on image tile URLs, use the `--basemap-tiles-url`
option to provide a raster tile URL pattern:

```
--basemap https://some.host/{z}/{x}/{y}.png
```

The template parameters `{z}` (zoom), `{x}`, `{y}` are required.

The extension can be omitted or be any image format supported by MapLibre GL.

The URL can include query parameters as required by the host, such as
`?access_token=<something>`.

IMPORTANT: this does not support vector tiles.


## ArcGIS API

Expand Down
7 changes: 6 additions & 1 deletion handlers/serviceset.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type ServiceSetConfig struct {
EnableTileJSON bool
EnablePreview bool
EnableArcGIS bool
BasemapStyleURL string
BasemapTilesURL string
RootURL *url.URL
ErrorWriter io.Writer
}
Expand All @@ -30,8 +32,9 @@ type ServiceSet struct {
enableTileJSON bool
enablePreview bool
enableArcGIS bool
basemapStyleURL string
basemapTilesURL string

domain string
rootURL *url.URL
errorWriter io.Writer
}
Expand All @@ -50,6 +53,8 @@ func New(cfg *ServiceSetConfig) (*ServiceSet, error) {
enableTileJSON: cfg.EnableTileJSON,
enablePreview: cfg.EnablePreview,
enableArcGIS: cfg.EnableArcGIS,
basemapStyleURL: cfg.BasemapStyleURL,
basemapTilesURL: cfg.BasemapTilesURL,
rootURL: cfg.RootURL,
errorWriter: cfg.ErrorWriter,
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func init() {
panic(err)
}

t, err := template.ParseFS(templatesFS, "map.html", "map_gl.html")
t, err := template.ParseFS(templatesFS, "map.html")
if err != nil {
fmt.Errorf("Could not resolve template: %w", err)
panic(err)
Expand Down
Loading
Loading