This commit is contained in:
suyl
2021-05-11 16:45:27 +08:00
parent 577c3e4b48
commit 8e61c58fd5
2 changed files with 25 additions and 1 deletions

View File

@@ -425,6 +425,30 @@ func (a *API) GetCoordinateFromAddress(address string, cityInfo string) (lng, la
return lng, lat, 0
}
func (a *API) GetCoordinateFromAddressAll(address string, cityInfo string) (getCoordinateFromAddressByPageAllResult *GetCoordinateFromAddressByPageAllResult, err error) {
params := map[string]interface{}{
"address": address,
}
if cityInfo != "" {
params["city"] = cityInfo
}
result, err := a.AccessAPI("geocode/geo", params)
if err == nil {
if geocodes, ok := result["geocodes"].([]interface{}); ok && len(geocodes) > 0 {
geocode := geocodes[0].(map[string]interface{})
locationList := strings.Split(utils.Interface2String(geocode["location"]), ",")
if len(locationList) > 1 {
getCoordinateFromAddressByPageAllResult.Lng = utils.Str2Float64WithDefault(locationList[0], 0)
getCoordinateFromAddressByPageAllResult.Lat = utils.Str2Float64WithDefault(locationList[1], 0)
}
getCoordinateFromAddressByPageAllResult.CityName = geocode["city"].(string)
getCoordinateFromAddressByPageAllResult.AdName = geocode["district"].(string)
}
}
return getCoordinateFromAddressByPageAllResult, err
}
func (a *API) GeoCodeRegeo(coords []*Coordinate, radius int, isExt bool, poiTypes []string, roadLevel, homeOrCorp int) (coordInfoList []*RegeoCodeInfo, err error) {
coordStrList := make([]string, len(coords))
for k, v := range coords {