How to simulate my position in my app like GPS does?
I want to do this from Additional Tools -> Location
Example to use on your emulator:
private void button2_Click(object sender, RoutedEventArgs e)
{
BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();
// You can specify a label and a geocoordinate for the end point.
// GeoCoordinate spaceNeedleLocation = new GeoCoordinate(47.6204,-122.3493);
// LabeledMapLocation spaceNeedleLML = new LabeledMapLocation("Space Needle", spaceNeedleLocation);
// If you set the geocoordinate parameter to null, the label parameter is used as a search term.
LabeledMapLocation spaceNeedleLML = new LabeledMapLocation("Space Needle", null);
bingMapsDirectionsTask.End = spaceNeedleLML;
// If bingMapsDirectionsTask.Start is not set, the user's current location is used as the start point.
bingMapsDirectionsTask.Show();
}
You need a
GeoCoordinateWatcherto listen for GPS positions. Later, when getting the first position, you initialize theLabeledMapLocationwith the coordinates given by the event arguments and start the map task.Example:
(First, add
System.Deviceto your project`s references.)And in the emulator you can click around on the Bing map to change your current position as you like.
You should also register for
watcher.StatusChanged. This event tells you for example when GPS becomes unavailable.