Exemple #1
0
 public async void UpdateMap(bool userLocation = false)
 {
     //if (myAzure.GetData(). await myAzure.GetData();
     myAzure.startGetDataTask();
     map.Children.Clear();
     if (userLocation)
     {
         var pin = new Grid()
         {
             Width  = 40,
             Height = 40,
             Margin = new Windows.UI.Xaml.Thickness(-12)
         };
         pin.Children.Add(new Ellipse()
         {
             Fill   = new SolidColorBrush(Colors.Red),
             Width  = 40,
             Height = 40
         });
         pin.Children.Add(new Ellipse()
         {
             Fill = new SolidColorBrush(Colors.Yellow),
             //Stroke = new SolidColorBrush(Colors.White),
             //StrokeThickness = 3,
             Width  = 25,
             Height = 25
         });
         MapLayer.SetPosition(pin, new Location(navigation.y, navigation.x));
         map.Children.Add(pin);
         if (slowView)
         {
             map.SetView(new Location(navigation.y, navigation.x), 19, 20, TimeSpan.FromSeconds(4));
         }
     }
     if (myAzure.items != null)
     {
         foreach (var item in myAzure.items)
         {
             if (!string.Equals(item.Id, navigation.guid))
             {
                 //MapIcon MapIcon1 = new MapIcon();
                 //MapIcon1.Location = new Geopoint(new BasicGeoposition()
                 //{
                 //    Latitude = 47.620,
                 //    Longitude = -122.349
                 //});
                 //MapIcon1.NormalizedAnchorPoint = new Point(0.5, 1.0);
                 //MapIcon1.Title = "Space Needle";
                 //MapControl1.MapElements.Add(MapIcon1);
                 var pin = new Grid()
                 {
                     Width  = 400,
                     Height = 400,
                     Margin = new Windows.UI.Xaml.Thickness(-12)
                 };
                 pin.Children.Add(new TextBlock()
                 {
                     Text     = item.Name,
                     FontSize = 25,
                     Width    = 400,
                     Height   = 400
                 });
                 MapLayer.SetPosition(pin, new Location(item.Y + 0.00001, item.X + 0.0001));
                 map.Children.Add(pin);
                 Pushpin pushpin = new Pushpin();
                 pushpin.Text    = item.Name;
                 pushpin.Tapped += Pushpin_Tapped;
                 MapLayer.SetPosition(pushpin, new Location(item.Y, item.X));
                 map.Children.Add(pushpin);
             }
         }
     }
     //myAzure.StartInsertDataTask();
     await myAzure.InsertData(new TableItem(navigation.guid, navigation.name, navigation.x, navigation.y, DateTime.Now));
 }
        public async void UpdateMap(bool userLocation = false)
        {
            map.Children.Clear();
            if (userLocation)
            {
                var pin = new Grid()
                {
                    Width  = 25,
                    Height = 25,
                    Margin = new Windows.UI.Xaml.Thickness(-12)
                };
                pin.Children.Add(new Ellipse()
                {
                    Fill   = new SolidColorBrush(Colors.Red),
                    Width  = 25,
                    Height = 25
                });
                pin.Children.Add(new Ellipse()
                {
                    Fill   = new SolidColorBrush(Colors.Yellow),
                    Width  = 10,
                    Height = 10
                });
                var basic = new BasicGeoposition();
                basic.Longitude = navigation.x;
                basic.Latitude  = navigation.y;
                Windows.UI.Xaml.Shapes.Ellipse fence = new Windows.UI.Xaml.Shapes.Ellipse();
                map.Children.Add(pin);
                MapControl.SetLocation(pin, new Geopoint(basic));
                MapControl.SetNormalizedAnchorPoint(pin, new Point(0.5, 0.5));
                if (slowView)
                {
                    await map.TrySetViewAsync(new Geopoint(basic), 19, 20, 20, MapAnimationKind.Bow);
                }
            }
            //await myAzure.GetData();
            myAzure.startGetDataTask();
            map.MapElements.Clear();
            if (myAzure.items != null)
            {
                foreach (var item in myAzure.items)
                {
                    if (!string.Equals(item.Id, navigation.guid))
                    {
                        MapIcon mapIcon = new MapIcon();
                        ////mapIcon.Image = RandomAccessStreamReference.CreateFromUri(
                        // //new Uri("ms-appx:///Assets/marker.png"));
                        var basic = new BasicGeoposition();
                        basic.Longitude = item.X;
                        basic.Latitude  = item.Y;
                        ////basic.Altitude = item.z;
                        var point = new Geopoint(basic);
                        mapIcon.NormalizedAnchorPoint = new Point(0.25, 0.9);
                        mapIcon.Location = point;
                        map.MapElements.Add(mapIcon);

                        var pin = new Grid()
                        {
                            Width  = 100,
                            Height = 30,
                            Margin = new Windows.UI.Xaml.Thickness(-12)
                        };
                        pin.Children.Add(new TextBlock()
                        {
                            Text       = item.Name,
                            Foreground = new SolidColorBrush(Colors.Black),
                            FontSize   = 15,
                            Width      = 100,
                            Height     = 30
                        });
                        map.Children.Add(pin);
                        MapControl.SetLocation(pin, new Geopoint(basic));
                        MapControl.SetNormalizedAnchorPoint(pin, new Point(0.5, 0.5));
                    }
                }
            }
            await myAzure.InsertData(new TableItem(navigation.guid, navigation.name, navigation.x, navigation.y, DateTime.Now));
        }