Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
85bccea0
Commit
85bccea0
authored
Aug 25, 2025
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
11
parent
8d546a10
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
35 deletions
+11
-35
HttpHelper.cs
Mall.Common/Plugin/HttpHelper.cs
+11
-35
No files found.
Mall.Common/Plugin/HttpHelper.cs
View file @
85bccea0
...
...
@@ -224,20 +224,20 @@ namespace Mall.Common.Plugin
/// <returns></returns>
public
static
string
[]
GetGeocoderLatitude
(
string
address
)
{
string
apiKey
=
"7d9fbeb43e975cd1e9477a7e5d5e192a"
;
var
returnStr
=
new
string
[
2
]
{
""
,
""
};
HttpClient
client
=
new
HttpClient
();
string
url
=
"http://api.map.baidu.com/geocoder?address="
+
address
+
"&output=json&key="
+
apiKey
;
try
{
string
apiResult
=
client
.
GetStringAsync
(
url
).
Result
;
var
apiJson
=
JObject
.
Parse
(
apiResult
);
var
resultJson
=
JObject
.
Parse
(
apiJson
[
"result"
].
ToString
());
var
locationJson
=
JObject
.
Parse
(
resultJson
[
"location"
].
ToString
());
var
lng
=
locationJson
[
"lng"
].
ToString
();
//经度
var
lat
=
locationJson
[
"lat"
].
ToString
();
//纬度
returnStr
[
0
]
=
lng
;
returnStr
[
1
]
=
lat
;
//string apiKey = "7d9fbeb43e975cd1e9477a7e5d5e192a";
//string url = "http://api.map.baidu.com/geocoder?address=" + address + "&output=json&key=" + apiKey;
//string apiResult = client.GetStringAsync(url).Result;
//var apiJson = JObject.Parse(apiResult);
//var resultJson = JObject.Parse(apiJson["result"].ToString());
//var locationJson = JObject.Parse(resultJson["location"].ToString());
//var lng = locationJson["lng"].ToString();//经度
//var lat = locationJson["lat"].ToString();//纬度
//returnStr[0] = lng;
//returnStr[1] = lat;
}
catch
{
...
...
@@ -246,31 +246,7 @@ namespace Mall.Common.Plugin
return
returnStr
;
}
/// <summary>
/// 根据经纬度获取详细地址location
/// </summary>
/// <param name="latlng"></param>
/// <returns></returns>
public
static
string
GetGeocoderAddress
(
string
latlng
)
{
string
apiKey
=
"7d9fbeb43e975cd1e9477a7e5d5e192a"
;
HttpClient
client
=
new
HttpClient
();
string
url
=
"http://api.map.baidu.com/geocoder?location="
+
latlng
+
"&output=json&key="
+
apiKey
;
try
{
string
apiResult
=
client
.
GetStringAsync
(
url
).
Result
;
var
apiJson
=
JObject
.
Parse
(
apiResult
);
var
resultJson
=
JObject
.
Parse
(
apiJson
[
"result"
].
ToString
());
var
locationJson
=
JObject
.
Parse
(
resultJson
[
"addressComponent"
].
ToString
());
var
province
=
locationJson
[
"province"
].
ToString
();
//省份
return
province
;
}
catch
{
}
return
""
;
}
/// <summary>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment