WPF地图应用程序 [英] WPF Maps Application

查看:87
本文介绍了WPF地图应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个vb.net地图应用程序,我需要开发成c#。下面是一段我无法弄清楚的代码。任何人都可以帮忙吗?



Hi,

I have a vb.net maps application that i need to develop into c#. Below is a piece of code that I cannot figure out. Can anyone help?

">

Private geoDoc As XDocument

Private Sub ShowGeocodeData()
        Dim responseStatus = geoDoc...<status>.Single.Value()</status>
        If (responseStatus = "OK") Then
            Dim formattedAddress = geoDoc...<formatted_address>(0).Value()
            Dim latitude = geoDoc...<location>(0).Element("lat").Value()
            Dim longitude = geoDoc...<location>(0).Element("lng").Value()
            Dim locationType = geoDoc...<location_type>(0).Value()

            AddressTxtBlck.Text = formattedAddress
            LatitudeTxtBlck.Text = latitude
            LongitudeTxtBlck.Text = longitude

            Select Case locationType
                Case "APPROXIMATE"
                    AccuracyTxtBlck.Text = "Approximate"
                Case "ROOFTOP"
                    AccuracyTxtBlck.Text = "Precise"
                Case Else
                    AccuracyTxtBlck.Text = "Approximate"
            End Select

            lat = Double.Parse(latitude)
            lng = Double.Parse(longitude)

            If (SaveButton.IsEnabled = False) Then
                SaveButton.IsEnabled = True
                RoadmapToggleButton.IsEnabled = True
                TerrainToggleButton.IsEnabled = True
            End If

        ElseIf (responseStatus = "ZERO_RESULTS") Then
            MessageBox.Show("Unable to show results for: " & vbCrLf & _
                            location, "Unknown Location", MessageBoxButton.OK, _
                            MessageBoxImage.Information)
            DisplayXXXXXXs()
            AddressTxtBox.SelectAll()
        End If
        ShowMapButton.IsEnabled = True
        ZoomInButton.IsEnabled = True
        ZoomOutButton.IsEnabled = True
        MapProgressBar.Visibility = Windows.Visibility.Hidden
    End Sub
</location_type></location></location>





我无法弄清楚代码粗体文字的含义。即Dim responseStatus = geoDoc ...< status> .Single.Value()



谢谢!



I cannot figure out the meaning of the bold text of code. i.e. Dim responseStatus = geoDoc...<status>.Single.Value()

Thanks!

推荐答案

geoDoc。< status> 是一个 IEnumerable< XElement>

单个是一个LINQ扩展方法 Enumerable.Single(Of TSource) [ ^ ]

单个返回IEnumerable中唯一的元素(在这种情况下为 XElement ),但如果IEnumerable包含0或多于1项,则抛出异常。

是<的属性code> XElement
geoDoc.<status> is an IEnumerable<XElement>
Single is a LINQ extension method Enumerable.Single(Of TSource)[^]
Single returns the one and only element in the IEnumerable (in this case an XElement), but throws an exception if the IEnumerable contains 0 or more than 1 item.
Value is a property of XElement






我正在努力与同一块代码:

Hi,

I am struggling with the same piece of code:
会员8192163写道:
Member 8192163 wrote:

Dim responseStatus = geoDoc ...< status> .Single .Value()

Dim responseStatus = geoDoc...<status>.Single.Value()





你现在找到了答案吗?



谢谢

Bernd



抱歉...我没有看到解决方案。他们在我发布我的问题后出现了。不介意......



Did you find an answer now?

Thanks
Bernd

Sorry... I did not see the solutions. They appeared after I posted my question. Don't mind...


这篇关于WPF地图应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆