Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to develop a windows phone 8.1 application.(not silverlight). I need to locate my current location and also nearest location. (i.e geographic points of interest within a given proximity (e.g. 10km) filtered by category, such as "restaurants","petrol bunks","hotels" etc.)

With the help of BingMapsTask we can do it in silverlight applications. So coming to wp8.1 I tried using launch uri. But I cannot get the current location and nearby selected category with this uri

C#
await Windows.System.Launcher.LaunchUriAsync(new Uri("bingmaps:?lvl=10&where=restaurants", UriKind.Absolute));


How to get the current nearby list of places
Posted

1 solution

First try to access your current location.
By using Windows.Devices.Geolocation, you can access that
C#
async private void GetLocation()
{
    var geolocator = new Geolocator();
    geolocator.DesiredAccuracyInMeters = 100;  // specify your range
    Geoposition position = await geolocator.GetGeopositionAsync();
    Geocoordinate coordinate = position.Coordinate;
    MessageBox.Show("Latitude = " + coordinate.Latitude + " Longitude = " + coordinate.Longitude); 
}

Refer this:
https://msdn.microsoft.com/en-us/library/windows/apps/jj206956(v=vs.105).aspx[^]
https://msdn.microsoft.com/en-us/library/windows/apps/jj735578(v=vs.105).aspx[^]
Using GPS for Getting Location in Windows Phone 8[^]

Now map your nearby places using your location.
C#
BingMapsTask bingMapsTask = new BingMapsTask();
bingMapsTask.Center = new GeoCoordinate(position.Coordinate.Latitude, position.Coordinate.Longitude);
bingMapsTask.ZoomLevel = 2;
bingMapsTask.SearchTerm = "restaurant";
bingMapsTask.Show();


-KR
 
Share this answer
 
Comments
sandy.L 16-Oct-15 10:12am    
Sir, BingMapsTask is not supported in windows phone 8.1 applications. How to implement this in windows phone 8.1 apps

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900