Mapbox API wrappers for Golang
See here for other golang/mapbox projects.
Very early WIP, pull requests and issues are most welcome. See lib/geocode/ or lib/directions/ for an example module to mimic.
Because Travis-CI does not expose the build environment to untrusted branches (ie. Pull Requests) tests have to be manually prompted by a repository admin then force merged. Don't panic when your local tests pass but travis fails with "Mapbox API token not found", we will manually run them as soon as possible. See issue #10 for more information.
// Import the core module (and any required APIs)
import (
"gopkg.in/ryankurte/go-mapbox.v0/lib"
"gopkg.in/ryankurte/go-mapbox.v0/lib/base"
)
// Fetch token from somewhere
token := os.Getenv("MAPBOX_TOKEN")
// Create new mapbox instance
mapBox := mapbox.NewMapbox(token)
import (
"gopkg.in/ryankurte/go-mapbox.v0/lib/maps"
)
img, err := mapBox.Maps.GetTiles(maps.MapIDSatellite, 1, 0, 0, maps.MapFormatJpg90, true)
import (
"gopkg.in/ryankurte/go-mapbox.v0/lib/geocode"
)
// Forward Geocoding
var forwardOpts geocode.ForwardRequestOpts
forwardOpts.Limit = 1
place := "2 lincoln memorial circle nw"
forward, err := mapBox.Geocode.Forward(place, &forwardOpts)
// Reverse Geocoding
var reverseOpts geocode.ReverseRequestOpts
reverseOpts.Limit = 1
loc := &base.Location{72.438939, 34.074122}
reverse, err := mapBox.Geocode.Reverse(loc, &reverseOpts)
import (
"gopkg.in/ryankurte/go-mapbox.v0/lib/directions"
)
var directionOpts directions.RequestOpts
locs := []base.Location{{-122.42, 37.78}, {-77.03, 38.91}}
directions, err := mapBox.Directions.GetDirections(locs, directions.RoutingCycling, &directionOpts)
If you have any questions, comments, or suggestions, feel free to open an issue or a pull request.