Hi everyone,
I am pretty new to Windows Phone app development, I working on a small app in which i need to display the current location of the user on the map. I tried it using following code snippet from a example. Is there a way to get the current location
coordinates ??? I heard using GPS we can get the current location lat,long values how can we get that ???
#code snippet
{
Geolocator myGeolocator = new Geolocator();
Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();
Geocoordinate myGeocoordinate = myGeoposition.Coordinate;
GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);
this.mapWithMyLocation.Center = myGeoCoordinate;
this.mapWithMyLocation.ZoomLevel = 14;
Ellipse myCircle = new Ellipse();
myCircle.Fill = new SolidColorBrush(Colors.Blue);
myCircle.Height = 20;
myCircle.Width = 20;
myCircle.Opacity = 50;
MapOverlay myLocationOverlay = new MapOverlay();
myLocationOverlay.Content = myCircle;
myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
myLocationOverlay.GeoCoordinate = myGeoCoordinate;
MapLayer myLocationLayer = new MapLayer();
myLocationLayer.Add(myLocationOverlay);
mapWithMyLocation.Layers.Add(myLocationLayer);
}
public static GeoCoordinate ConvertGeocoordinate(Geocoordinate geocoordinate)
{
return new GeoCoordinate
(
geocoordinate.Latitude,
geocoordinate.Longitude,
geocoordinate.Altitude ?? Double.NaN,
geocoordinate.Accuracy,
geocoordinate.AltitudeAccuracy ?? Double.NaN,
geocoordinate.Speed ?? Double.NaN,
geocoordinate.Heading ?? Double.NaN
);
}
My actual requirement is to display the location of user on the map. If i know the latitide, langitude values I able to do It, My major problem is finding them.
Any suggestion is Appreciated
MANIKANTA