【发布时间】: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