Documentation
¶
Index ¶
- Constants
- func AssignMapConfigHandler(opts *AssignMapConfigHandlerOptions, mux *http.ServeMux, map_cfg_uri string) error
- func MapConfigHandler(cfg *MapConfig) http.Handler
- func ProtomapsFileHandlerFromPath(path string, prefix string) (string, http.Handler, error)
- type AssignMapConfigHandlerOptions
- type InitialBounds
- type InitialView
- type LeafletConfig
- type LeafletStyle
- type MapConfig
- type ProtomapsConfig
Constants ¶
const LEAFLET_OSM_TILE_URL = "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
const PROTOMAPS_API_TILE_URL = "https://api.protomaps.com/tiles/v3/{z}/{x}/{y}.mvt?key={key}"
Variables ¶
This section is empty.
Functions ¶
func AssignMapConfigHandler ¶
func AssignMapConfigHandler(opts *AssignMapConfigHandlerOptions, mux *http.ServeMux, map_cfg_uri string) error
AssignMapConfigHandler derives a new `MapConfig` and corresponding `http.Handler` instance from 'opts' assigning to 'mux' at 'map_cfg_uri'.
func MapConfigHandler ¶
MapConfigHandler returns a new `http.Handler` that will return a JSON-encoded version of 'cfg'.
func ProtomapsFileHandlerFromPath ¶
ProtomapsFileHandlerFromPath 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 AssignMapConfigHandlerOptions ¶
type AssignMapConfigHandlerOptions struct { // A string label indicating the map provider to use. Valid options are: leaflet, protomaps. MapProvider string // A valid Leaflet tile layer URI. MapTileURI string // A comma-separated string indicating the map's initial view. Valid options are: 'LON,LAT', 'LON,LAT,ZOOM' or 'MINX,MINY,MAXX,MAXY'. InitialView string // A custom Leaflet style definition for geometries. This may either be a JSON-encoded string or a path on disk. LeafletStyle string // A custom Leaflet style definition for points. This may either be a JSON-encoded string or a path on disk. LeafletPointStyle string // A valid Protomaps theme label. ProtomapsTheme string }
AssignMapConfigHandlerOptions defines configuration options for the AssignMapConfigHandler method.
type InitialBounds ¶
type InitialBounds [4]float64
func (*InitialBounds) String ¶
func (v *InitialBounds) String() string
type InitialView ¶
type InitialView [2]float64
func (*InitialView) String ¶
func (v *InitialView) String() string
type LeafletConfig ¶
type LeafletConfig struct { Style *LeafletStyle `json:"style,omitempty"` PointStyle *LeafletStyle `json:"point_style,omitempty"` }
type LeafletStyle ¶
type LeafletStyle struct { Color string `json:"color,omitempty"` FillColor string `json:"fillColor,omitempty"` Weight float64 `json:"weight,omitempty"` Opacity float64 `json:"opacity,omitempty"` Radius float64 `json:"radius,omitempty"` FillOpacity float64 `json:"fillOpacity,omitempty"` }
LeafletStyle is a struct containing details for decorating GeoJSON features and markers
func UnmarshalLeafletStyle ¶
func UnmarshalLeafletStyle(raw string) (*LeafletStyle, error)
UnmarshalLeafletStyle derives a `LeafletStyle` instance from 'raw'. If 'raw' starts with "{" then it is treated as a JSON-encoded string, otherwise it is treated as a local path on disk.
func UnmarshalStyleFromReader ¶
func UnmarshalStyleFromReader(r io.Reader) (*LeafletStyle, error)
UnmarshalStyleFromString derives a `LeafletStyle` instance from the body of 'r'.
func UnmarshalStyleFromString ¶
func UnmarshalStyleFromString(raw string) (*LeafletStyle, error)
UnmarshalStyleFromString derives a `LeafletStyle` instance from 'raw'.
type MapConfig ¶
type MapConfig struct { // A valid map provider label. Provider string `json:"provider"` // A valid Leaflet tile layer URI. TileURL string `json:"tile_url"` // Optional Protomaps configuration details Protomaps *ProtomapsConfig `json:"protomaps,omitempty"` // Optional Leaflet configuration details Leaflet *LeafletConfig `json:"leaflet,omitempty"` // The initial view (lon, lat) for the map (optional). InitialView *InitialView `json:"initial_view,omitempty"` // The initial zoom level for the map (optional). InitialZoom int `json:"initial_zoom,omitempty"` // The initial bounds (minx, miny, maxx, maxy) for the map (optional). InitialBounds *InitialBounds `json:"initial_bounds,omitempty"` }
MapConfig defines common configuration details for maps.
type ProtomapsConfig ¶
type ProtomapsConfig struct { // A valid Protomaps theme label Theme string `json:"theme"` }
ProtomapsConfig defines configuration details for maps using Protomaps.