Bing映射文本框搜索

时间:2015-11-02 19:27:12

标签: vb.net xaml bing-maps bing bing-api

您好我正试图让我的Bing地图api读取一个文本框,该文本框中会有一个邮政编码或地址,它会找到。目前经过大量的反复试验,我已经通过坐标坐标进行搜索,坐标坐标直接输入到Xaml按钮内的标签选项中。我想知道是否有人知道如何添加文本框,用户可以简单地输入地址。

文本框(地址) - >按钮(点击)---->地图搜索

当前Xaml代码

<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="MainWindow"
Title="MainWindow" Height="350" Width="525">
<Grid >
    <m:Map CredentialsProvider="MY KEY" x:Name="BingMap">
        <Button Content="Button" HorizontalAlignment="Left" Height="30" VerticalAlignment="Top" Width="99" Margin="92,279,0,0" Click="ChangeMapView_Click" x:Name="BTN1" Tag="39.3683,-95.2734,0.0000 4.0000"/>
        <TextBox HorizontalAlignment="Left" Height="32" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="111" Margin="212,277,0,0" x:Name="TXT1"/>
    </m:Map>
</Grid>
</Window>

VB代码

   Private Sub ChangeMapView_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    ' Parse the information of the button's Tag property
    Dim tagInfo() As String = (CType(sender, Button)).Tag.ToString().Split(" "c)
    Dim center As Location = CType(locConverter.ConvertFrom(tagInfo(0)), Location)
    Dim zoom As Double = System.Convert.ToDouble(tagInfo(1))


    ' Set the map view
    BingMap.SetView(center, zoom)

End Sub

1 个答案:

答案 0 :(得分:0)

您必须将用户查询传递到Bing Maps REST地理编码服务才能获得它的坐标。您可以在此处找到有关如何执行此操作的文档:https://msdn.microsoft.com/en-us/library/hh757509.aspx