HomeWindowsHow to Get the Current Location and Display it on Map using MapsTask in WP8?

How to Get the Current Location and Display it on Map using MapsTask in WP8?

The GetGeoPositionAsync method of the Geolocator class can be used to get the Current Location from the Windows Phone 8.

In this blog post, let’s explore how to get the current location in Windows Phone 8 and display it on the Map using the MapsTask Launcher.

How to Get the Current Location and Display it on Map using MapsTask in WP8?

The Geolocator class is defined in the Windows.Devices.Geolocation namespace. To get the current location, just instantiate the Geolocator class and call the GetGeoPositionAsync method. Make sure that the ID_CAP_MAPS and ID_CAP_LOCATION capabilities are enabled in the WMAppManifest.xml file.

Below is a code snippet that get the current location using the Geolocator class and then displays it on the Map using MapsTask .

Geolocator Loc = new Geolocator();

Loc.DesiredAccuracy = PositionAccuracy.High;

Geoposition pos = await Loc.GetGeopositionAsync();

MapsTask mapTask = new MapsTask();

mapTask.ZoomLevel = 18;

mapTask.Center = new GeoCoordinate(pos.Coordinate.Latitude, pos.Coordinate.Longitude);

mapTask.Show();

The GetGeopositionAsync method of the Geolocator returns the Geoposition which has the latitude and longitude which is used to create the GeoCoordinate and then assign to the Center property of the Maps Task. When the Show method of the MapsTask is called, the built-in Maps Application is launched.

How to Get the Current Location and Display it on Map using MapsTask in WP8?

    1 Comment

  1. satyanarayana
    March 5, 2016
    Reply

    hi iam developing maps for windows phone my geo location, but it will show default US location did not show my location
    any one please help , i need urgent this projects
    my Projects is Destination Alert on Windows phone Maps

Leave a Reply

You May Also Like

This blog post will guide you through several effective methods to troubleshoot and resolve the issue of Microsoft Edge not...
Windows 11 offers a range of audio enhancements that can enrich your listening experience. These enhancements include features like virtual...
Windows 11 brings a fresh and visually stunning design to your desktop, and one of the standout features is the...