How to Get the Current Location and Pin it on the Map in Windows Phone 8?

Published on March 24, 2014 by abundantcode

Filed under Windows Phone

Last modified March 24, 2014

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 3123 times

Are you looking to find the current location in the Windows Phone using c# and later pin it on to the map? Below is a sample code snippet that demonstrates how to achieve it.

How to Get the Current Location and Pin it on the Map in Windows Phone 8?

Code to get the Current Location

private async Task<GeoCoordinate> GetCurrentLocation()

{

   Geolocator Loc = new Geolocator();

   Loc.DesiredAccuracy = PositionAccuracy.High;

   Geoposition pos = await Loc.GetGeopositionAsync();

   return new GeoCoordinate(pos.Coordinate.Latitude, pos.Coordinate.Longitude);

}

Code to Plot the Location to Map using MapsTask

MapsTask mapTask = new MapsTask();

mapTask.ZoomLevel = 18;

mapTask.Center = await GetCurrentLocation();;

mapTask.Show();
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Comment


x

You might be Interested in these Posts

How to delete user account from command line in Windows 10 ?

You can delete a user account from command line in Windows 10 using the net user command and specify...

How to add new user account from command line in Windows 10 ?

You can add a new user account in Windows 10 using command prompt using the net user command and pas...

How to open display settings from command line in Windows 10 ?

The display properties can be found in the settings app in Windows 10 which lets the users to config...