1
This commit is contained in:
@@ -2,6 +2,7 @@ package baidunavi
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
@@ -210,7 +211,7 @@ func (a *API) BatchCoordinateConvert(coords []*Coordinate, fromCoordSys, toCoord
|
||||
|
||||
result, err := a.AccessAPI2("geoconv/v1/", params)
|
||||
if err == nil {
|
||||
err = utils.Map2StructByJson(result, &outCoords, false)
|
||||
err = utils.Map2StructByJson(result[resultKey], &outCoords, false)
|
||||
}
|
||||
return outCoords, err
|
||||
}
|
||||
@@ -231,13 +232,13 @@ func (a *API) DirectionLiteRide(coords []*Coordinate) (retVal interface{}, err e
|
||||
|
||||
resp, err := a.AccessAPI2(apiStr, param)
|
||||
if err == nil {
|
||||
return resp, nil
|
||||
return resp[resultKey], nil
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (a *API) AccessAPI2(apiStr string, param url.Values) (retVal interface{}, err error) {
|
||||
func (a *API) AccessAPI2(apiStr string, param url.Values) (retVal map[string]interface{}, err error) {
|
||||
|
||||
for _, v := range BaiduAKList {
|
||||
param.Add("ak", v)
|
||||
@@ -264,9 +265,12 @@ func (a *API) AccessAPI2(apiStr string, param url.Values) (retVal interface{}, e
|
||||
if err1 != nil || err2 != nil {
|
||||
continue
|
||||
}
|
||||
result := string(body)
|
||||
//result := string(body)
|
||||
//result := map[string]interface{}{}
|
||||
|
||||
err = json.Unmarshal(body, &retVal)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
return retVal, nil
|
||||
}
|
||||
}
|
||||
return nil, errors.New("所有百度应用额度均用完")
|
||||
|
||||
Reference in New Issue
Block a user