google

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	URL = "https://maps.googleapis.com/maps/api/geocode/json"
)

Variables

This section is empty.

Functions

func AutoLocate

func AutoLocate()

func IPLocate

func IPLocate()

func Locate

func Locate()

Types

type Config

type Config struct {
	APIKey  string `json:"api_key,omitempty"`
	Enabled bool   `json:"enabled,omitempty"`
}

type Google

type Google struct {
	APIKey         string
	LocationString string
}

func New

func New(apiKey, locationString string) *Google

func (Google) GetLocation

func (g Google) GetLocation() (geocoder.Location, error)

type Response

type Response struct {
	Results []struct {
		AddressComponents []struct {
			LongName  string   `json:"long_name"`
			ShortName string   `json:"short_name"`
			Types     []string `json:"types"`
		} `json:"address_components"`
		FormattedAddress string `json:"formatted_address"`
		Geometry         struct {
			Bounds map[string]struct {
				Latitude  float64 `json:"lat"`
				Longitude float64 `json:"lng"`
			} `json:"bounds"`
			Location struct {
				Latitude  float64 `json:"lat"`
				Longitude float64 `json:"lng"`
			} `json:"location"`
			LocationType string `json:"location_type"`
			Viewport     map[string]struct {
				Latitude  float64 `json:"lat"`
				Longitude float64 `json:"lng"`
			} `json:"viewport"`
		} `json:"geometry"`
		PlaceID string   `json:"place_id"`
		Types   []string `json:"types"`
	} `json:"results"`

	Status       string `json:"status"`
	ErrorMessage string `json:"error_message"`
}

Jump to

Keyboard shortcuts

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