【问题标题】:Bing maps textbox search必应地图文本框搜索
【发布时间】:2015-11-02 19:27:12
【问题描述】:

您好,我正在尝试让我的 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

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-01
      相关资源
      最近更新 更多