有没有更好的方法使用VB.NET从谷歌地图获取Sublocality?

时间:2012-06-22 09:42:44

标签: vb.net google-maps

有没有更好的方法从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

0 个答案:

没有答案