有没有更好的方法从sublocality
使用VB.Net获取Google Map API
?感谢。
Dim SubLocality As String = "--"
Dim xelement As XElement = xelement.Load(String.Format("http://maps.googleapis.com/maps/api/geocode/xml?latlng={0},{1}&sensor=false", 3.1424342, 101.710032))
If String.Compare(xelement.Element("status").Value, "OK", True) = 0 Then
For Each c As XElement In xelement.Element("result").Elements
If String.Compare(c.Name.ToString, "address_component", True) = 0 Then
If c.Elements("type").Any() Then
For Each d As XElement In c.Elements
If String.Compare(d.Name.ToString, "type") = 0 Then
If String.Compare(d.Value.ToString, "sublocality") = 0 Then
MsgBox(c.Elements("long_name").Value)
Exit
End If
End If
Next
End If
End If
Next
End If