private void SetMapIconPosition(DependencyObject icon, Models.Geoposition geoLocation, Point anchorPoint) { var nativeCoordinate = CoordinateConverter.ConvertToNative(geoLocation); MapControl.SetLocation(icon, nativeCoordinate); MapControl.SetNormalizedAnchorPoint(icon, anchorPoint); }
public override async Task <IEnumerable <Models.Geoposition> > CalculateRoute(Models.Geoposition from, Models.Geoposition to) { Geopoint nativeFrom = CoordinateConverter.ConvertToNative(from); Geopoint nativeTo = CoordinateConverter.ConvertToNative(to); MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync( nativeFrom, nativeTo, MapRouteOptimization.Time, MapRouteRestrictions.None); List <Models.Geoposition> result = new List <Models.Geoposition>(); IReadOnlyList <BasicGeoposition> routePositions = routeResult?.Route?.Path?.Positions; if (routePositions?.Any() == true) { foreach (BasicGeoposition position in routePositions) { result.Add(new Models.Geoposition { Latitude = position.Latitude, Longitude = position.Longitude }); } } return(result); }
protected override async void AddIncidentToMap(IncidentModel incident) { var geoLocation = CoordinateConverter.ConvertToNative(incident.GeoLocation); var mapIcon = new MapIcon(); mapIcon.CollisionBehaviorDesired = MapElementCollisionBehavior.RemainVisible; mapIcon.Location = geoLocation; mapIcon.NormalizedAnchorPoint = new Point(0.5, 1.0); mapIcon.ZIndex = 1000; var iconImageUri = default(Uri); switch (incident.IncidentCategory) { case IncidentType.Alert: iconImageUri = new Uri("ms-appx:///Assets/Pins/pin_alert.png"); break; case IncidentType.Animal: iconImageUri = new Uri("ms-appx:///Assets/Pins/pin_animal.png"); break; case IncidentType.Arrest: iconImageUri = new Uri("ms-appx:///Assets/Pins/pin_arrest.png"); break; case IncidentType.Car: iconImageUri = new Uri("ms-appx:///Assets/Pins/pin_car.png"); break; case IncidentType.Fire: iconImageUri = new Uri("ms-appx:///Assets/Pins/pin_siren.png"); break; case IncidentType.OfficerRequired: iconImageUri = new Uri("ms-appx:///Assets/Pins/pin_officer.png"); break; case IncidentType.Stranger: iconImageUri = new Uri("ms-appx:///Assets/Pins/pin_stranger.png"); break; default: iconImageUri = new Uri("ms-appx:///Assets/Pins/pin_car.png"); break; } RandomAccessStreamReference stream = RandomAccessStreamReference.CreateFromUri(iconImageUri); mapIcon.Image = await stream.ScaleTo(40, 58); _nativeMap.MapElements.Add(mapIcon); _pushpinMappings.Add(mapIcon, incident.Id); }