예제 #1
0
        void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
        {
            Dispatcher.BeginInvoke(() =>
            {
                Geocoordinate myGeocoordinate = args.Position.Coordinate;
                myMap.SetView(myGeocoordinate.ToGeoCoordinate(), 16, MapAnimationKind.Linear);


                UserLocationMarker newPin = (UserLocationMarker)this.FindName("UserLocationMarker");
                newPin.GeoCoordinate      = myGeocoordinate.ToGeoCoordinate();
            });
        }
예제 #2
0
        /*For see you location on the map*/
        private async void ShowMyLocationOnTheMap()
        {
            // Get my current location.
            Geolocator  myGeolocator  = new Geolocator();
            Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();

            Geocoordinate myGeocoordinate = myGeoposition.Coordinate;
            GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);

            // Make my current location the center of the Map.
            //MessageBox.Show("Latitude" + myGeoCoordinate.Latitude+ "Longitud: " + myGeoCoordinate.Longitude + "Altitud:"+myGeoCoordinate.Altitude);
            place = myGeocoordinate.ToGeoCoordinate().ToString();
            this.mapWithMyLocation.Center    = myGeoCoordinate;
            this.mapWithMyLocation.ZoomLevel = 13;
            // Create a small circle to mark the current location.
            Ellipse myCircle = new Ellipse();

            myCircle.Fill    = new SolidColorBrush(Colors.Blue);
            myCircle.Height  = 20;
            myCircle.Width   = 20;
            myCircle.Opacity = 50;
            // Create a MapOverlay to contain the circle.
            MapOverlay myLocationOverlay = new MapOverlay();

            myLocationOverlay.Content        = myCircle;
            myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
            myLocationOverlay.GeoCoordinate  = myGeoCoordinate;
            // Create a MapLayer to contain the MapOverlay.
            MapLayer myLocationLayer = new MapLayer();

            myLocationLayer.Add(myLocationOverlay);
            // Add the MapLayer to the Map.
            mapWithMyLocation.Layers.Add(myLocationLayer);
        }