|
In this simple and small article I will talk about BingMapsTask in Windows Phone which is present in Sytem.Device.Location.
Let's write code
Step 1: Create a Silverlight for Windows Phone project.
Step 2: Add a textbox and a button inside ContentPanel of MainPage.xaml.
<TextBox Height="72" FontSize="22" HorizontalAlignment="Left" Margin="0,375,0,0" Name="txtSearch" VerticalAlignment="Top" Width="460" />
<Button x:Name="bingMap" Margin="0,340,0,0" Height="80" Width="460" Click="bingMap_Click" Content="Search" />
Step 3: Add reference of System.Device.
Step 4: Add below using directive in MainPage.Xaml.cs
using System.Device.Location;
Step 5: Add below method in MainPage.Xaml.cs
private void bingMap_Click(object sender, RoutedEventArgs e) { BingMapsTask bingMapsTask = new BingMapsTask(); bingMapsTask.Center = new GeoCoordinate(15.109, 90.618); bingMapsTask.SearchTerm = txtSearch.Text; bingMapsTask.ZoomLevel = 2; bingMapsTask.Show(); }
Step 6: In above method GeoCoordinate method takes latitude and longitude. You can retrieve current latitude and longitude by following this article
This ends the article of BingMapsTask in Windows Phone.
|