I was writing an windows phone application using visual phone sdk which give me location of entered address. I was able to do it(Look at below code) but it always redirect to bing maps in next page. But I wanted to add a map and a text field at same page. I will enter the location in text field and maps will show the location (using bing map of visual studio). Is there some good example which I can refer too. It will be a great help.
namespace PhoneApp3
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
BingMapsTask bmt = new BingMapsTask();
GeoCoordinateWatcher gcw = new GeoCoordinateWatcher();
public MainPage()
{
InitializeComponent();
map1.CredentialsProvider = new ApplicationIdCredentialsProvider("Your API Key");
}
private void button1_Click(object sender, RoutedEventArgs e)
{
GeoCoordinate gc = new GeoCoordinate(47,-127);
bmt.Center = gc;
bmt.ZoomLevel = 9;
LocationRect.CreateLocationRect(gc);
bmt.Show();
//gcw.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(gcw_PositionChanged);
//gcw.Start();
}
void gcw_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
textBox1.Text = e.Position.Location.Latitude.ToString();
textBox2.Text = e.Position.Location.Longitude.ToString();
}
private void button2_Click(object sender, RoutedEventArgs e)
{
BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();
GeoCoordinate gc1 = new GeoCoordinate(47,-126);
GeoCoordinate gc2 = new GeoCoordinate(47, -127);
//LabeledMapLocation lml = new LabeledMapLocation("IIT Powai",)
LabeledMapLocation spaceNeedleLML = new LabeledMapLocation("",gc1);
LabeledMapLocation spaceNeedleLML2 = new LabeledMapLocation("",gc2);
bingMapsDirectionsTask.End = spaceNeedleLML;
bingMapsDirectionsTask.Start = spaceNeedleLML2;
// If bingMapsDirectionsTask.Start is not set, the user's current location is used as the start point.
bingMapsDirectionsTask.Show();
}
}
}