Categorygithub.com/aaronland/go-http-maps
modulepackage
0.4.0
Repository: https://github.com/aaronland/go-http-maps.git
Documentation: pkg.go.dev

# README

go-http-maps

Go package providing opinionated HTTP middleware for web-based map tiles.

Important

This is work in progress. Documentation is incomplete.

Until then have a look at app/server/server.go, templates/html/map.html and static/javascript/aaronland.map.init.js for an example of working code.

tools

server

An example HTTP server demonstrating the use of the go-http-maps package.

> ./bin/server -h
  -initial-latitude float
    	The starting latitude to position the map at. (default 37.61799)
  -initial-longitude float
    	The start longitude to position the map at. (default -122.370943)
  -initial-zoom int
    	The starting zoom level to position the map at. (default 12)
  -javascript-at-eof
    	An optional boolean flag to indicate that JavaScript resources (<script> tags) should be appended to the end of the HTML output.
  -leaflet-enable-draw
    	Enable the Leaflet.Draw plugin.
  -leaflet-enable-fullscreen
    	Enable the Leaflet.Fullscreen plugin.
  -leaflet-enable-hash
    	Enable the Leaflet.Hash plugin. (default true)
  -leaflet-tile-url string
    	A valid Leaflet 'tileLayer' layer URL. Only necessary if -map-provider is "leaflet".
  -map-prefix string
    	...
  -map-provider string
    	The name of the map provider to use. Valid options are: leaflet, null, protomaps
  -protomaps-bucket-uri string
    	The gocloud.dev/blob.Bucket URI where Protomaps tiles are stored. Only necessary if -map-provider is "protomaps" and -protomaps-serve-tiles is true.
  -protomaps-caches-size int
    	The size of the internal Protomaps cache if serving tiles locally. Only necessary if -map-provider is "protomaps" and -protomaps-serve-tiles is true. (default 64)
  -protomaps-database string
    	The name of the Protomaps database to serve tiles from. Only necessary if -map-provider is "protomaps" and -protomaps-serve-tiles is true.
  -protomaps-label-rules-uri gocloud.dev/runtimevar
    	// An optional gocloud.dev/runtimevar URI referencing a custom Javascript variable used to define Protomaps label rules.
  -protomaps-paint-rules-uri gocloud.dev/runtimevar
    	// An optional gocloud.dev/runtimevar URI referencing a custom Javascript variable used to define Protomaps paint rules.
  -protomaps-serve-tiles
    	A boolean flag signaling whether to serve Protomaps tiles locally. Only necessary if -map-provider is "protomaps".
  -protomaps-tile-url string
    	A valid Protomaps .pmtiles URL for loading map tiles. Only necessary if -map-provider is "protomaps". (default "/tiles/")
  -rollup-assets
    	An optional boolean flag to indicate that multiple JavaScript and CSS assets should be minified and combined in to single files.
  -server-uri string
    	A valid aaronland/go-http-server URI (default "http://localhost:8080")

Example

protomaps

go run -mod vendor cmd/server/main.go \
	-map-provider protomaps \
	-protomaps-serve-tiles \
	-protomaps-bucket-uri file:///{PATH_TO}/go-http-maps/fixtures
	-protomaps-database sfo

leafet

go run -mod vendor cmd/server/main.go \
	-map-provider leaflet
	-leaflet-tile-url https://tile.openstreetmap.org/{z}/{x}/{y}.png

See also

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

Append all the files in the net/http FS instance containing the embedded Maps assets to an *http.ServeMux instance.
AppendResourcesHandler will rewrite any HTML produced by previous handler to include the necessary markup to load Maps JavaScript and CSS files and related assets.
No description provided by the author
Return a *MapsOptions struct with default paths and URIs.

# Structs

MapsOptions provides a list of JavaScript and CSS link to include with HTML output.