baidu

package
v0.0.0-...-1ec2636 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AK     = "FGV8C3GjFeAGstAa1INmabge"
	APIKEY = "98d278cdc3fdb4e71b1469bdfd144624"
)

Variables

View Source
var ZXS []string = []string{"北京市", "天津市", "重庆市", "上海市", "澳门特别行政区", "香港特别行政区"}

Functions

func GetCityByGPS

func GetCityByGPS(pos lbs.Coordinate) (city, province string, e error)

根据GPS获取城市

func GetCityByIP

func GetCityByIP(ip string) (province, city string, e error)

根据IP获取城市

func GetCityByPhone

func GetCityByPhone(phone string) (city, province, supplier string, e error)

根据手机号码获取城市

func GetGPSByCity

func GetGPSByCity(city string, province string) (pos lbs.Coordinate, e error)

根据城市获取GPS

func IsZXS

func IsZXS(province string) bool

是否是直辖市

Types

type CityByPhoneResult

type CityByPhoneResult struct {
	ErrNum  int    `json:"errNum"`
	ErrMsg  string `json:"errMsg"`
	RetData struct {
		Province string `json:"province"`
		City     string `json:"city"`
		Supplier string `json:"Supplier"`
	} `json:"retData"`
}

type CityGPSResult

type CityGPSResult struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
	Result  struct {
		Location struct {
			Lat float64 `json:"lat"`
			Lng float64 `json:"lng"`
		} `json:"location"`
	} `json:"result"`
}

type CityNum

type CityNum struct {
	Name string `json:"name"`
	Num  int    `json:"num"`
}

func SearchProvince

func SearchProvince(province string, cur, ps int, keywords ...string) (cities []CityNum, total int, e error)

SearchProvince在省范围内根据关键字搜索实体,关键词之间是或的关系,搜索结果返回省内城市存在匹配结果的数量。

参数:

province: 省或者“全国”,如果是直辖市则返回空数组
cur: 请求的页码,从1开始
ps: 每页的数量,不能超过20
keywords: 搜索关键词

type CityNumResult

type CityNumResult struct {
	Status  int       `json:"status"`
	Message string    `json:"message"`
	Total   int       `json:"total"`
	Results []CityNum `json:"results"`
}

type GPSCityResult

type GPSCityResult struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
	Result  struct {
		Address struct {
			Distict  string `json:"district"`
			City     string `json:"city"`
			Province string `json:"province"`
		} `json:"addressComponent"`
	} `json:"result"`
}

type IPAddressResult

type IPAddressResult struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
	Content struct {
		AddressDetail struct {
			City     string `json:"city"`
			Province string `json:"province"`
		} `json:"address_detail"`
	} `json:"content"`
}

type Place

type Place struct {
	Name     string `json:"name"`
	Uid      string `json:"uid"`
	Location struct {
		Lat float64 `json:"lat"`
		Lng float64 `json:"lng"`
	} `json:"location"`
	Address string `json:"address"`
}

func SearchCity

func SearchCity(city string, cur, ps int, keywords ...string) (places []Place, total int, e error)

SearchRegion在城市范围内根据关键字搜索实体,关键词之间是或的关系。

参数:

cur: 请求的页码,从1开始
ps: 每页的数量,不能超过20
keywords: 搜索关键词

func SearchPlace

func SearchPlace(lat, lng float64, radius, cur, ps int, sortByDistence bool, keywords ...string) (places []Place, total int, e error)

SearchPlace根据关键字搜索附近的实体,关键词之间是或的关系。

参数:

lat,lng: 中心点,经纬度
radius: 半径,米
cur: 请求的页码,从1开始
ps: 每页的数量,不能超过20
sortByDistence: 是否按距离排序,如果为false,则根据百度地图的默认排序规则(貌似是根据热度排序)
keywords: 搜索关键词

type PlaceResult

type PlaceResult struct {
	Status  int     `json:"status"`
	Message string  `json:"message"`
	Total   int     `json:"total"`
	Results []Place `json:"results"`
}

type Suggestion

type Suggestion struct {
	Name     string `json:"name"`
	Uid      string `json:"uid"`
	Location struct {
		Lat float64 `json:"lat"`
		Lng float64 `json:"lng"`
	} `json:"location"`
	City     string `json:"city"`
	CityId   string `json:"cityid"`
	District string `json:"district"`
}

func SuggestionPlace

func SuggestionPlace(region string, keyword string, coordinate ...float64) (sugestions []Suggestion, e error)

SuggestionPlace根据用户输入返回建议的结果。

参数:

region: 区域,例如"北京市"
coordinate: 中心点,经纬度(先纬度后经度),如果传这两个值,则以此坐标为中心返回建议结果。
keyword: 搜索关键词

type SuggestionResult

type SuggestionResult struct {
	Status  int          `json:"status"`
	Message string       `json:"message"`
	Results []Suggestion `json:"result"`
}

Jump to

Keyboard shortcuts

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