go_amap

package module
v0.0.0-...-a657041 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 11 Imported by: 0

README

go-amap

介绍

golang版的高德地图 api

安装教程
go get gitee.com/yjsoft-sh/go-amap
例子
package main

import (
    go_amap "gitee.com/yjsoft-sh/go-amap"
)

func main() {
	key := ""
	secret := "" //如需要签名
	amapSdk := go_amap.NewAmapClient(key,secret )
	amapSdk.Location.IpLocation("121.224.33.99")
}

位置相关
  • client.Location.ipLocation() 根据ip地址获取位置信息
  • client.Location.Geo() 地址解析,根据结构化地址获取经纬度城市等信息
  • client.Location.ReGeo() 逆向地址解析,根据经纬度获取结构化的地址信息
  • client.Location.ChinaDistricts() 获取中国的所有地区,到县级
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllDistrictResponse

type AllDistrictResponse struct {
	Response

	Count     int `json:"count,string"`
	Districts []*District
}

type AmapClient

type AmapClient struct {
	Location *Location
	// contains filtered or unexported fields
}

func NewAmapClient

func NewAmapClient(key, secret string) *AmapClient

func (*AmapClient) DoRequest

func (a *AmapClient) DoRequest(url, method string, params url.Values) (resp *http.Response, err error)

type District

type District struct {
	Citycode  any         `json:"citycode"`
	Adcode    string      `json:"adcode"`
	Name      string      `json:"name"`
	Center    string      `json:"center"`
	Level     string      `json:"level"`
	Districts []*District `json:"districts"`
}

type Geo

type Geo struct {
	FormattedAddress string `json:"formatted_address"`
	Country          string `json:"country"`
	Province         string `json:"province"`
	Citycode         string `json:"citycode"`
	City             any    `json:"city"`
	Adcode           string `json:"adcode"`
	Location         string `json:"location"`
	Level            string `json:"level"`
}

type GeoResponse

type GeoResponse struct {
	Response

	Count    string `json:"count"`
	GeoCodes []Geo  `json:"geocodes"`
}

type IpResponse

type IpResponse struct {
	Response
	Province  string `json:"province"`
	City      any    `json:"city"`
	Adcode    string `json:"adcode"`
	Rectangle string `json:"rectangle"`
}

type Location

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

func (*Location) ChinaDistricts

func (l *Location) ChinaDistricts() ([]*District, error)

func (*Location) Geo

func (l *Location) Geo(address, city string) (*GeoResponse, error)

func (*Location) IpLocation

func (l *Location) IpLocation(ip string) (*IpResponse, error)

func (*Location) ReGeo

func (l *Location) ReGeo(request *ReGeoRequest) (*ReGeoResponse, error)

type ReGeoRequest

type ReGeoRequest struct {
	Location string
	//PoiType    string
	Radius int
}

type ReGeoResponse

type ReGeoResponse struct {
	Response

	ReGeoCode struct {
		FormattedAddress string `json:"formatted_address"`
		AddressComponent struct {
			City     any    `json:"city"`
			Country  string `json:"country"`
			Province string `json:"province"`
			Citycode string `json:"citycode"`
			District string `json:"district"`
			Adcode   string `json:"adcode"`
			Township string `json:"township"`
			Towncode string `json:"towncode"`
		} `json:"addressComponent"`
	} `json:"regeocode"`
}

type Response

type Response struct {
	Status   string `json:"status"`
	Info     string `json:"info"`
	Infocode string `json:"Infocode"`
}

Jump to

Keyboard shortcuts

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