예제 #1
0
        public async void ShowLocationOnMap()
        {
            Geolocator  geolocator  = new Geolocator();
            Geoposition geoposition = await geolocator.GetGeopositionAsync();   // Get geolocation

            Geocoordinate geocoordinate = geoposition.Coordinate;

            geoCoordinate = CoordinateConverter.ConvertGeocoordinate(geocoordinate); // Convert to a maps control compatible class

            map.Center    = geoCoordinate;                                           // Set current location as the centre of the map
            map.ZoomLevel = 13;

            // Create blue circle shown in app
            Ellipse marker = new Ellipse();

            marker.Fill    = new SolidColorBrush(Colors.Blue);
            marker.Height  = 20;
            marker.Width   = 20;
            marker.Opacity = 50;

            // Overlay blue circle on map control
            MapOverlay mapOverlay = new MapOverlay();

            mapOverlay.Content        = marker;
            mapOverlay.PositionOrigin = new Point(0.5, 0.5);
            mapOverlay.GeoCoordinate  = geoCoordinate;

            MapLayer mapLayer = new MapLayer();

            mapLayer.Add(mapOverlay);

            map.Layers.Add(mapLayer);
        }
예제 #2
0
        async void GetUserLocation()
        {
            Geolocator geolocator = new Geolocator();
            Geoposition geoposition = await geolocator.GetGeopositionAsync();
            Geocoordinate geocoordinate = geoposition.Coordinate;
            departure = CoordinateConverter.ConvertGeocoordinate(geocoordinate);

            //System.Diagnostics.Debug.WriteLine(departure.Longitude);
            //System.Diagnostics.Debug.WriteLine(departure.Latitude);
        }