geo

package module
v0.0.0-...-0afeffe Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2016 License: MIT Imports: 6 Imported by: 4

README

geo

Just a simple go wrapper for the Google Geocoding API (https://developers.google.com/maps/documentation/geocoding/)

Usage:

package main

import 	(
	"fmt"
	"github.com/jasonmoo/geo"	
)

add, err := geo.Geocode("555 w 18th st, ny, ny")

fmt.Println(add)

add2, err2 := geo.ReverseGeocode("40.7453721,-74.0078293")

fmt.Println(add2)

>> &geo.Address{Lat:40.7453721, Lng:-74.0078293, Address:"555 W 18th St, New York, NY 10011, USA", Response:(*geo.Response)(0x11185d60)}

Documentation

Index

Constants

View Source
const (
	StatusOk             = "OK"
	StatusZeroResults    = "ZERO_RESULTS"
	StatusOverQueryLimit = "OVER_QUERY_LIMIT"
	StatusRequestDenied  = "REQUEST_DENIED"
	StatusInvalidRequest = "INVALID_REQUEST"
)

Variables

View Source
var (
	RemoteServerError = errors.New("Unable to contact the goog.")
	BodyReadError     = errors.New("Unable to read the response body.")
)

Functions

This section is empty.

Types

type Address

type Address struct {
	Lat      float64   `json:"lat"`
	Lng      float64   `json:"lng"`
	Address  string    `json:"address"`
	Response *Response `json:"response"`
}

func Geocode

func Geocode(q string) (*Address, error)

func ReverseGeocode

func ReverseGeocode(ll string) (*Address, error)

func (*Address) String

func (a *Address) String() string

type AddressComponent

type AddressComponent struct {
	LongName  string   `json:"long_name"`
	ShortName string   `json:"short_name"`
	Types     []string `json:"types"`
}

type GeometryData

type GeometryData struct {
	Location     LatLng `json:"location"`
	LocationType string `json:"location_type"`
	Viewport     struct {
		Southwest LatLng `json:"southwest"`
		Northeast LatLng `json:"northeast"`
	} `json:"viewport"`
	Bounds struct {
		Southwest LatLng `json:"southwest"`
		Northeast LatLng `json:"northeast"`
	} `json:"bounds"`
}

type LatLng

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

type Response

type Response struct {
	Status  string   `json:"status"`
	Results []Result `json:"results"`
}

type Result

type Result struct {
	Types             []string           `json:"types"`
	FormattedAddress  string             `json:"formatted_address"`
	AddressComponents []AddressComponent `json:"address_components"`
	Geometry          GeometryData       `json:"geometry"`
}

Jump to

Keyboard shortcuts

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