void DrawOnePoint(double _lat, double _long) { try { MyMap.Center = new Windows.Devices.Geolocation.Geopoint(new BasicGeoposition { Latitude = _lat, Longitude = _long }); MyMap.ZoomLevel = 18; MapIcon MeAsMapIcon1 = new Windows.UI.Xaml.Controls.Maps.MapIcon(); // MeAsMapIcon1.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/pushpin.png")); MeAsMapIcon1.Location = new Geopoint(new BasicGeoposition() { Latitude = _lat, Longitude = _long }); MeAsMapIcon1.NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 1.0); MeAsMapIcon1.Title = "المكان التانى"; MyMap.MapElements.Add(MeAsMapIcon1); } catch { } }
async void DrawRouteBetweenMeAndSpecificPoint(double _lat, double _long) { try { ClearMap(); BasicGeoposition startLocation = new BasicGeoposition(); startLocation.Latitude = MyPositionLatitude; startLocation.Longitude = MyPositionLongitude; Geopoint startPoint = new Geopoint(startLocation); BasicGeoposition endLocation = new BasicGeoposition(); endLocation.Latitude = _lat; endLocation.Longitude = _long; Geopoint endPoint = new Geopoint(endLocation); string from = MyPositionLatitude.ToString() + "," + MyPositionLongitude.ToString(); string to = _lat.ToString() + "," + _long.ToString(); if (!string.IsNullOrWhiteSpace(from)) { if (!string.IsNullOrWhiteSpace(to)) { // Get a route as shown previously. MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync( startPoint, endPoint, MapRouteOptimization.Time, MapRouteRestrictions.None); MapIcon MeAsMapIcon = new Windows.UI.Xaml.Controls.Maps.MapIcon(); MeAsMapIcon.Location = new Geopoint(new BasicGeoposition() { Latitude = MyPositionLatitude, Longitude = MyPositionLongitude }); MeAsMapIcon.NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 1.0); MeAsMapIcon.Title = "أنا"; MyMap.MapElements.Add(MeAsMapIcon); MapIcon thereAsMapIcon = new Windows.UI.Xaml.Controls.Maps.MapIcon(); thereAsMapIcon.Location = new Geopoint(new BasicGeoposition() { Latitude = _lat, Longitude = _long }); thereAsMapIcon.NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 1.0); thereAsMapIcon.Title = "المكان التانى"; MyMap.MapElements.Add(thereAsMapIcon); if (routeResult.Status == MapRouteFinderStatus.Success) { // Use the route to initialize a MapRouteView. MapRouteView viewOfRoute = new MapRouteView(routeResult.Route); viewOfRoute.RouteColor = Colors.DarkBlue; viewOfRoute.OutlineColor = Colors.White; // Add the new MapRouteView to the Routes collection // of the MapControl. MyMap.Routes.Add(viewOfRoute); // Fit the MapControl to the route. await MyMap.TrySetViewBoundsAsync( routeResult.Route.BoundingBox, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.None); } } else { ShowMessage("Invalid 'To' location."); } } else { ShowMessage("Invalid 'From' location."); } } catch { } }
async void GetMyLication() { try { Geolocator geo = null; if (geo == null) { geo = new Geolocator(); } Geoposition pos = await geo.GetGeopositionAsync(); MyMap.Center = new Windows.Devices.Geolocation.Geopoint(new BasicGeoposition { Latitude = pos.Coordinate.Point.Position.Latitude, Longitude = pos.Coordinate.Point.Position.Longitude }); MyPositionLatitude = pos.Coordinate.Point.Position.Latitude; MyPositionLongitude = pos.Coordinate.Point.Position.Longitude; MyMap.ZoomLevel = 18; MapIcon MeAsMapIcon1 = new Windows.UI.Xaml.Controls.Maps.MapIcon(); // MeAsMapIcon1.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/MapPin.png")); MeAsMapIcon1.Location = new Geopoint(new BasicGeoposition() { Latitude = pos.Coordinate.Point.Position.Latitude, Longitude = pos.Coordinate.Point.Position.Longitude }); //MeAsMapIcon1.NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 1.0); //MeAsMapIcon1.Title = "أنا"; //MyMap.MapElements.Add(MeAsMapIcon1); } catch { } }