Search code examples
c#.netxamlgpswindows-store-apps

Get Geolocation from a tapped point . windows store project (c#)


I'm creating an aplication that uses a mapcontrol and i want to get geolocations based on tapped point from an user, but i don't know how to get it. There is no solutions in another questions in stackoverflow that worked for me.

I've download the bing.maps extension , but i can´t reference it. Thete are the namespaces that i'm using .

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.Devices.Geolocation;
using Windows.UI.Xaml.Shapes;
using Windows.UI.Xaml.Controls.Maps;
using Windows.UI;
using Windows.Phone;
using Windows.Storage.Streams;

i've search on internet and i found a method in MapControl class. (MapControl.GetLocationFromOffset). it could works? and how to use it ... i know that this exist but i can't create a variable to store this value ... GeoLocator .. GeoPoint .. GeoCoordinate, var .. object , none of this works for me.

someone knows how to convert a tapped point to an geocoordinate (latitude and longitude)?


Solution

  • To respond to the user tapping the map, I assume you have a handler set up for the MapControl's MapTapped event. One of the arguments for the handler is a MapInputEventArgs which has a property Location. This is a GeoPoint, and you should be able to get Lat/Lon from it.