333
This commit is contained in:
parent
f454ae0417
commit
f695fbbdc6
|
|
@ -170,7 +170,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||||
var (result, message) = resultTuple.Value;
|
var (result, message) = resultTuple.Value;
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
geocodedAddress = result.Regeocode.Formatted_Address;
|
geocodedAddress = result;
|
||||||
}
|
}
|
||||||
regeo = message ?? "";
|
regeo = message ?? "";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
ZR.Admin.WebApi/gift/2025/0807/1754569878_7326.jpg
Normal file
BIN
ZR.Admin.WebApi/gift/2025/0807/1754569878_7326.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 105 KiB |
BIN
ZR.Admin.WebApi/gift/2025/0807/1754569913_7214.jpg
Normal file
BIN
ZR.Admin.WebApi/gift/2025/0807/1754569913_7214.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 105 KiB |
BIN
ZR.Admin.WebApi/gift/2025/0807/1754569925_2040.jpg
Normal file
BIN
ZR.Admin.WebApi/gift/2025/0807/1754569925_2040.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 105 KiB |
BIN
ZR.Admin.WebApi/gift/2025/0807/1754570095_2396.jpg
Normal file
BIN
ZR.Admin.WebApi/gift/2025/0807/1754570095_2396.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 105 KiB |
BIN
ZR.Admin.WebApi/gift/2025/0807/1754570111_2513.jpg
Normal file
BIN
ZR.Admin.WebApi/gift/2025/0807/1754570111_2513.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 105 KiB |
|
|
@ -20,7 +20,7 @@ public class GeoCodeService
|
||||||
_httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
|
_httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(ReGeoCodeResult, string)?> GetReGeoCodeAsync(string location, string coordsys = "gcj02")
|
public async Task<(string, string)?> GetReGeoCodeAsync(string location, string coordsys = "gcj02")
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(location))
|
if (string.IsNullOrWhiteSpace(location))
|
||||||
{
|
{
|
||||||
|
|
@ -33,19 +33,22 @@ public class GeoCodeService
|
||||||
{
|
{
|
||||||
var response = await _httpClient.GetAsync(requestUrl);
|
var response = await _httpClient.GetAsync(requestUrl);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
var content = await response.Content.ReadAsStringAsync();
|
var content = await response.Content.ReadAsStringAsync();
|
||||||
|
var json = JsonDocument.Parse(content);
|
||||||
|
|
||||||
var result = JsonConvert.DeserializeObject<ReGeoCodeResult>(content);
|
// 直接提取 formatted_address
|
||||||
|
var j = json.RootElement
|
||||||
return new(result, content);
|
.GetProperty("regeocode")
|
||||||
|
.GetProperty("formatted_address")
|
||||||
|
.GetString();
|
||||||
|
return new(j, content);
|
||||||
}
|
}
|
||||||
catch (HttpRequestException ex)
|
catch (HttpRequestException ex)
|
||||||
{
|
{
|
||||||
//throw new ApplicationException("Error calling AMap API", ex);
|
//throw new ApplicationException("Error calling AMap API", ex);
|
||||||
|
|
||||||
}
|
}
|
||||||
return new(null, "");
|
return new("", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user