我正在尝试使用2个地址之间的bing maps api来获取汽车的行驶距离。
到目前为止,我已经获得了返回带有数据的JSON文件的链接,但是不确定如何获取;设置;结果存入基本类变量。
链接:var url =“ http://dev.virtualearth.net/REST/V1/Routes/Driving?wp.0=11+streetname+parish+city+Postcode&wp.1=3+DestinationStreet+DestinationParish+DestinationPostcode&optimizeWaypoints=true&distanceUnit=mi&key=我的BING API密钥
这将返回以下JSON(仅一部分):
{
"authenticationResultCode": "ValidCredentials",
"brandLogoUri": "http://dev.virtualearth.net/Branding/logo_powered_by.png",
"copyright": "Copyright © 2018 Microsoft and its suppliers. All rights
reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.",
"resourceSets": [
{
"estimatedTotal": 1,
"resources": [
{
"__type": "Route:http://schemas.microsoft.com/search/local/ws/rest/v1",
"bbox": [
53.4669,
-1.24426,
53.48046,
-1.19207
],
"id": "v69,h-704643067,i0,a0,cen-US,dAAAAAAAAAAA1,y0,s1,m1,o1,t4,wsyPVd369SkDytPzAVR7zvw2~AxDMnWdxYwgCAADgAS8AJj8A0~MzMgQmFpbmVzIEF2ZW51ZSwgRG9uY2FzdGVyLCBETjEyIDFQUSwgVW5pdGVkIEtpbmdkb201~~~~v11,w1xcJbTm9SkCMg0vHnOfzvw2~AxDMnWdhYwYCAADgAcWQTz4A0~MyBMaWxhYyBHcm92ZSwgRG9uY2FzdGVyLCBETjEyIDJKTCwgVW5pdGVkIEtpbmdkb201~~~~v11,k0",
"distanceUnit": "Mile",
"durationUnit": "Second",
"routeLegs": [
{
"actualEnd": {
"type": "Point",
"coordinates": [
53.478315,
-1.244046
]
},
"actualStart": {
"type": "Point",
"coordinates": [
53.480423,
-1.194906
]
},
"alternateVias": [],
"cost": 0,
"description": "B6376, B6094",
"endLocation": {
"bbox": [
53.477323,
-1.245981,
53.479571,
-1.242203
],
"name": "Address of first way point",
"point": {
"type": "Point",
"coordinates": [
53.478447,
-1.244092
]
},
如何读取此文件/在班级中设置经度/纬度和地址等数据?