maps

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package maps shows a map in a window's native UI: MapKit on iOS, and on Android osmdroid, with OpenStreetMap's tiles by default, which needs no account or key.

m, err := maps.New(win, maps.Options{Center: maps.LatLng{Lat: 48.86, Lng: 2.35}, Zoom: 12})
...
ui.WebView(c, m).Fill() // in the view; what it draws after shows over the map
m.OnTap(func(at maps.LatLng) { ... })
m.AddMarker(ctx, maps.Marker{ID: "home", At: at, Title: "Home"})

A finger pans, pinches and taps it. OpenStreetMap's tile servers are for light use: an app with many users gives Options.TileURL a server of its own (Android; iOS shows Apple's maps). On desktops and in browsers New reports errors.ErrUnsupported.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LatLng

type LatLng struct {
	Lat float64 `json:"lat"`
	Lng float64 `json:"lng"`
}

LatLng is a place, in degrees.

type Map

type Map struct {
	// contains filtered or unexported fields
}

Map is a map in a window. Show it with ui.WebView.

func New

func New(w *mygo.Window, o Options) (*Map, error)

New makes a map in a window showing native UI.

func (*Map) AddMarker

func (m *Map) AddMarker(ctx context.Context, marker Marker) error

AddMarker puts a pin on the map, in place of one of its ID.

func (*Map) Camera

func (m *Map) Camera(ctx context.Context) (center LatLng, zoom float64, err error)

Camera returns what the map shows now, as the user panned it.

func (*Map) Destroy

func (m *Map) Destroy()

Destroy takes the map away, which closing its window doesn't: call it before.

func (*Map) OnMarkerTap

func (m *Map) OnMarkerTap(fn func(id string))

OnMarkerTap calls fn on the main thread as a finger taps a pin.

func (*Map) OnTap

func (m *Map) OnTap(fn func(at LatLng))

OnTap calls fn on the main thread as a finger taps the map, not one of its pins.

func (*Map) RemoveMarker

func (m *Map) RemoveMarker(ctx context.Context, id string) error

RemoveMarker takes a pin off the map.

func (*Map) SetCamera

func (m *Map) SetCamera(ctx context.Context, center LatLng, zoom float64, animated bool) error

SetCamera moves the map to a place, gliding there if animated.

func (*Map) SurfaceWebView

func (m *Map) SurfaceWebView(conn *surface.Conn) platform.WebView

SurfaceWebView gives package ui the view to show.

type Marker

type Marker struct {
	// ID tells it apart: OnMarkerTap reports it, and adding it again moves it.
	ID string `json:"id"`
	At LatLng `json:"at"`
	// Title shows as it's tapped.
	Title string `json:"title,omitempty"`
}

Marker is a pin on a map.

type Options

type Options struct {
	Center LatLng
	// Zoom is as on web maps: 0 shows the whole world, 18 a street; 2 by default.
	Zoom float64
	// TileURL is where Android's map gets its tiles, with {z}, {x} and {y}; by
	// default OpenStreetMap's.
	TileURL string
}

Options say what a map shows first.

Jump to

Keyboard shortcuts

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