优化整体
This commit is contained in:
+5
-5
@@ -12,21 +12,21 @@ type BaiduMap struct {
|
||||
Url string
|
||||
}
|
||||
|
||||
func (this *BaiduMap) Init(Ak string) {
|
||||
func (that *BaiduMap) Init(Ak string) {
|
||||
//"ak=ZeT902EZvVgIoGVWEFK3osUm"
|
||||
this.Ak = Ak
|
||||
this.Url = "https://api.map.baidu.com/place/v2/suggestion?output=json" + "&ak=" + Ak
|
||||
that.Ak = Ak
|
||||
that.Url = "https://api.map.baidu.com/place/v2/suggestion?output=json" + "&ak=" + Ak
|
||||
//query
|
||||
}
|
||||
|
||||
// GetPosition 获取定位列表
|
||||
func (this *BaiduMap) GetPosition(name string, region string) (string, error) {
|
||||
func (that *BaiduMap) GetPosition(name string, region string) (string, error) {
|
||||
|
||||
client := &http.Client{}
|
||||
if region == "" {
|
||||
region = "全国"
|
||||
}
|
||||
reqest, err := http.NewRequest("GET", this.Url+"&query="+url.PathEscape(name)+"®ion="+url.PathEscape(region), nil)
|
||||
reqest, err := http.NewRequest("GET", that.Url+"&query="+url.PathEscape(name)+"®ion="+url.PathEscape(region), nil)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Fatal error ", err.Error())
|
||||
|
||||
Reference in New Issue
Block a user