问题描述
有一段简单的代码,给定 LATitude 和 LONgitude,检索地址。 使用可选的 mapquest、ARCGiS 或 BING。在 propertygridBox 中显示结果。
Dim AdressofPoint As New BingMapsRESTService.Common.JSON.Address
url = "http://dev.virtualearth.net/REST/v1/Locations/47.64054,-122.12934?&key=" + apikey
xmlhttpRequest.open("GET",url)
xmlhttpRequest.send()
responsetext = xmlhttpRequest.responseText
'AdressofPoint = Newtonsoft.Json.JsonConvert.DeserializeObject(Of BingMapsRESTService.Common.JSON.Address)(responsetext)
AdressofPoint = System.Text.Json.JsonSerializer.Deserialize(Of BingMapsRESTService.Common.JSON.Address)(responsetext)
Return AdressofPoint ' to set the Selectedobject property of propertygrid object) (System.Windows.Forms.PropertyGrid)
ARCGIS 和 mapquest 很好,BING 的问题是属性网格框显示字段名称但不显示值。所有返回的值(Admindistrict、locality、postalcode.....)都是空的(什么都没有)。这似乎是一个反序列化问题。由于它是几行代码,我尝试了许多不同的版本,例如:
- 输出 XML / JSON
- 从返回的 JSON 创建类(粘贴 Json 作为 VS2019) / 实施数据契约 https://docs.microsoft.com/en-us/bingmaps/rest-services/json-data-contracts
- System.Text / NewtonSoft 解串器
返回的 responsetext(或 responsexml)没有问题,并且包含值!
{
"authenticationResultCode": "ValidCredentials","brandlogoUri": "http:\/\/dev.virtualearth.net\/branding\/logo_powered_by.png","copyright": "copyright © 2021 Microsoft and its suppliers. All rights reserved.","resourceSets": [
{
"estimatedTotal": 1,"resources": [
{
"__type": "Location:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1","bBox": [
47.636677282429325,-122.13698331308882,47.644402717570678,-122.12169668691118
],"name": "156th Ave NE,Redmond,WA 98052","point": {
"type": "Point","coordinates": [
47.64054,-122.12934
]
},"address": {
"addressLine": "156th Ave NE","admindistrict": "WA","admindistrict2": "King Co.","countryRegion": "United States","formattedAddress": "156th Ave NE,"locality": "Overlake","postalCode": "98052"
},"confidence": "Medium","entityType": "Address","geocodePoints": [
{
"type": "Point","coordinates": [
47.64054,-122.12934
],"calculationMethod": "Interpolation","usageTypes": [
"display","Route"
]
}
],"matchCodes": [
"Good"
]
}
]
}
],"statusCode": 200,"statusDescription": "OK","traceId": "XXXXXXXXXXXXXXXXXXXXXXXX|BN000044D7|0.0.0.1|BN01EAP000009A3"
}
有什么想法吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)