protomaps

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2021 License: BSD-3-Clause Imports: 9 Imported by: 6

README

go-http-protomaps

Go HTTP middleware for the Protomaps Leaflet package.

Documentation

Documentation remains to be written. In the meantime have a look at the cmd/example/main.go application.

Tools

$> make cli
go build -mod vendor -o bin/example cmd/example/main.go
example

A simple example web application that uses the go-http-protomaps middleware and displays a map.

$> ./bin/example -h
Usage of ./bin/example:
  -protomaps-tile-url string
    	A custom file://, http:// or https:// URI pointing to a valid Protomaps tiles bundle. (default "/sfo.pmtiles")
  -server-uri string
    	A valid aaronland/go-http-server URI (default "http://localhost:8080")

The example application contains an embedded Protomaps tiles database file so the easiest way to test things is like this:

$> ./bin/example 
2021/04/28 07:45:57 Listening for requests on http://localhost:8080

And then when you open the URL http://localhost:8080 in your web browser you should see something like this:

The example application also supports loading .pmtiles databases from remote locations. For example:

$> ./bin/example -protomaps-tile-url https://static.sfomuseum.org/pmtiles/sfo.pmtiles
2021/04/28 07:48:11 Listening for requests on http://localhost:8080

If you want to load a local file you'd do this:

$> ./bin/example -protomaps-tile-url file:///usr/local/data/sfo.pmtiles
2021/04/28 07:48:53 Listening for requests on http://localhost:8080

In the case of file:// URLs the example application will create an http.Dir handler for the root folder of the URL (/usr/local/data/) and then route the filename (/sfo.pmtiles) to that handler.

See also

Documentation

Index

Constants

This section is empty.

Variables

View Source
var INCLUDE_LEAFLET = true

Functions

func AppendAssetHandlers

func AppendAssetHandlers(mux *http.ServeMux) error

func AppendAssetHandlersWithPrefix

func AppendAssetHandlersWithPrefix(mux *http.ServeMux, prefix string) error

func AppendResourcesHandler

func AppendResourcesHandler(next http.Handler, opts *ProtomapsOptions) http.Handler

func AppendResourcesHandlerWithPrefix

func AppendResourcesHandlerWithPrefix(next http.Handler, opts *ProtomapsOptions, prefix string) http.Handler

func AssetsHandler

func AssetsHandler() (http.Handler, error)

func AssetsHandlerWithPrefix

func AssetsHandlerWithPrefix(prefix string) (http.Handler, error)

func FileHandlerFromPath added in v0.0.3

func FileHandlerFromPath(path string, prefix string) (string, http.Handler, error)

FileHandlerFromPath will take a path and create a http.FileServer handler instance for the files in its root directory. The handler is returned with a relative URI for the filename in 'path' to be assigned to a net/http ServeMux instance.

Types

type ProtomapsOptions

type ProtomapsOptions struct {
	JS      []string
	CSS     []string
	TileURL string
}

func DefaultProtomapsOptions

func DefaultProtomapsOptions() *ProtomapsOptions

Directories

Path Synopsis
cmd
example command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL