private async void myMap_Loaded(object sender, RoutedEventArgs e) { if (myMap.Layers.Count == 0) { // Specify a known location. var cityPosition = new windows.Devices.Geolocation.BasicGeoposition() { Latitude = 47.604, Longitude = -122.329 }; var cityCenter = new windows.Devices.Geolocation.Geopoint(cityPosition); var icon = new windows.UI.Xaml.Controls.Maps.MapIcon() { Location = cityCenter, }; var elements = new System.Collections.Generic.List <windows.UI.Xaml.Controls.Maps.MapElement>() { icon, }; var layer = new windows.UI.Xaml.Controls.Maps.MapElementsLayer() { ZIndex = 1, MapElements = elements, }; myMap.Layers.Add(layer); // Set the map location. await myMap.TrySetViewAsync(cityCenter, 12).ConfigureAwait(false); } }
private async void DrawFlightPlane() { List<Windows.Devices.Geolocation.BasicGeoposition> geopoints = new List<Windows.Devices.Geolocation.BasicGeoposition>(); //Windows.Devices.Geolocation.Geopath geopath = new Windows.Devices.Geolocation.Geopath() List<Windows.UI.Xaml.Controls.Maps.MapIcon> waypointIcons = new List<Windows.UI.Xaml.Controls.Maps.MapIcon>(); foreach (DataModel.XNavpoint point in flightplan.Waypoints) { navpoints.Add(point); geopoints.Add(new Windows.Devices.Geolocation.BasicGeoposition() { Longitude = double.Parse(point.Longtitude) / 1000000 - 0.000005, Latitude = double.Parse(point.Lantitude) / 1000000 - 0.000005 }); System.Diagnostics.Debug.WriteLine(double.Parse(point.Longtitude) / 1000000 + " " + double.Parse(point.Lantitude) / 1000000); Windows.UI.Xaml.Controls.Maps.MapIcon icon = new Windows.UI.Xaml.Controls.Maps.MapIcon(); icon.Image = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/navpoint.png")); icon.Location = new Windows.Devices.Geolocation.Geopoint(new Windows.Devices.Geolocation.BasicGeoposition() { Latitude = double.Parse(point.Lantitude) / 1000000 - 0.000005, Longitude = double.Parse(point.Longtitude)/1000000 - 0.000005 }); icon.NormalizedAnchorPoint = new Point(0.5, 1.0); icon.Title = point.PointName; waypointIcons.Add(icon); } Windows.Devices.Geolocation.Geopath geopath = new Windows.Devices.Geolocation.Geopath(geopoints); await rootFrame.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { Windows.UI.Xaml.Controls.Maps.MapControl themap = (Windows.UI.Xaml.Controls.Maps.MapControl)rootFrame.FindName("themap"); Windows.UI.Xaml.Controls.Maps.MapPolyline line = new Windows.UI.Xaml.Controls.Maps.MapPolyline(); line.Path = geopath; line.StrokeColor = Windows.UI.Colors.Red; line.StrokeDashed = true; line.StrokeThickness = 3; themap.MapElements.Clear(); themap.MapElements.Add(line); foreach(Windows.UI.Xaml.Controls.Maps.MapIcon icon in waypointIcons) { themap.MapElements.Add(icon); } }); }
private async void Map_MapTapped(Windows.UI.Xaml.Controls.Maps.MapControl sender, Windows.UI.Xaml.Controls.Maps.MapInputEventArgs args) { if (setStartPending) { // get position Geopoint myPoint = new Geopoint(new BasicGeoposition() { Latitude = args.Location.Position.Latitude, Longitude = args.Location.Position.Longitude }); //create POI startIcon = new Windows.UI.Xaml.Controls.Maps.MapIcon { Location = myPoint, NormalizedAnchorPoint = new Point(0.5, 1.0), Title = "Start", ZIndex = 0 }; map.MapElements.Add(startIcon); setStartPending = false; return; } if (setEndPending) { // get position Geopoint myPoint = new Geopoint(new BasicGeoposition() { Latitude = args.Location.Position.Latitude, Longitude = args.Location.Position.Longitude }); //create POI endIcon = new Windows.UI.Xaml.Controls.Maps.MapIcon { Location = myPoint, NormalizedAnchorPoint = new Point(0.5, 1.0), Title = "End", ZIndex = 0 }; map.MapElements.Add(endIcon); setEndPending = false; return; } int zoomLevel = Math.Min(14, Math.Max(1, (int)sender.ZoomLevel)); var tileAddr = MapUtil.WorldToTilePos(args.Location.Position.Longitude, args.Location.Position.Latitude, zoomLevel); System.Diagnostics.Debug.WriteLine($"{args.Location.Position.Latitude}, {args.Location.Position.Longitude}"); Map_MapTapped((int)tileAddr.X, (int)tileAddr.Y, zoomLevel); }
private async void Timer_Tick(object sender, object e) { try { //emotion api calling float humidity = BMP280.GetHumidity(); float temperature = BMP280.GetTemperature(); Scores scores = await client.RecognizeAsync(Person[PersonIndex]); HappyModel model = new HappyModel(Store[StoreIndex].StoreName, temperature, humidity, Store[StoreIndex].Longitude.ToString(), Store[StoreIndex].Latitude.ToString(), scores); DisplayModel(model); //Image setting Image img = sender as Image; BitmapImage bitmapImage = new BitmapImage(); bitmapImage.UriSource = new Uri(Person[PersonIndex]); imgPerson.Source = bitmapImage; //Map Setting Windows.Devices.Geolocation.BasicGeoposition geo = new Windows.Devices.Geolocation.BasicGeoposition(); geo.Latitude = Store[StoreIndex].Latitude; geo.Longitude = Store[StoreIndex].Longitude; Windows.UI.Xaml.Controls.Maps.MapIcon icon = new Windows.UI.Xaml.Controls.Maps.MapIcon(); icon.Location = new Windows.Devices.Geolocation.Geopoint(geo); icon.NormalizedAnchorPoint = new Point(1, 1); icon.Title = Store[StoreIndex].StoreName; mapStoreLocation.MapElements.Clear(); mapStoreLocation.MapElements.Add(icon); await mapStoreLocation.TrySetViewAsync(new Windows.Devices.Geolocation.Geopoint(geo), 18, 0, 0, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.Bow); //IoTHubProxy data sending try { IoTProxy.SendMessage(model); } catch (Exception ex) { Debug.WriteLine("IoTHub======" + ex.Message); } PersonIndex++; StoreIndex++; //Init index if (PersonIndex == Person.Count() - 1) { PersonIndex = 0; } if (StoreIndex == Store.Count() - 1) { StoreIndex = 0; } } catch (Exception ex) { Debug.WriteLine("System======" + ex.Message); } }