Ejemplo n.º 1
0
        void RenderRoute()
        {
            layer.Children.Clear();

            Microsoft.Phone.Controls.Maps.MapPolyline line = new Microsoft.Phone.Controls.Maps.MapPolyline();
            line.Locations = new Microsoft.Phone.Controls.Maps.LocationCollection();

            double maxLat = DataContextManager.SelectedRoute.RoutePoints[0].Latitude;
            double minLat = DataContextManager.SelectedRoute.RoutePoints[0].Latitude;
            double maxLon = DataContextManager.SelectedRoute.RoutePoints[0].Longitude;
            double minLon = DataContextManager.SelectedRoute.RoutePoints[0].Longitude;

            foreach (MobileSrc.Commuter.Shared.GpsLocation location in DataContextManager.SelectedRoute.RoutePoints)
            {
                line.Locations.Add(new System.Device.Location.GeoCoordinate(location.Latitude, location.Longitude, location.Altitude));

                maxLat = Math.Max(maxLat, location.Latitude);
                minLat = Math.Min(minLat, location.Latitude);
                maxLon = Math.Max(maxLon, location.Longitude);
                minLon = Math.Min(minLon, location.Longitude);
            }
            Microsoft.Phone.Controls.Maps.LocationRect rect = new Microsoft.Phone.Controls.Maps.LocationRect(maxLat, minLon, minLat, maxLon);

            line.Opacity         = 0.65;
            line.StrokeThickness = 5;
            line.Visibility      = System.Windows.Visibility.Visible;
            line.Stroke          = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue);
            layer.Children.Add(line);

            if (_setViewPort)
            {
                BingMap.SetView(rect);
            }
        }
 private void WaitForStopDownloadingComplete(Exception ex)
 {
     if (null != _finalRect)
     {
         BingMap.SetView(_finalRect);
     }
 }
Ejemplo n.º 3
0
        private void ShowLocation(object sender, MouseEventArgs e)
        {
            var poi = LBTripPlan.SelectedItem as PointOfInterest;

            if (poi != null)
            {
                BingMap.SetView(new Microsoft.Maps.MapControl.WPF.Location()
                {
                    Latitude  = poi.Lat,
                    Longitude = poi.Long
                }, 16);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Draw pin elements on the map.
 /// </summary>
 public void DrawElements()
 {
     //Clear pins
     SatanController.HandleMap.ClearMap();
     //Player pin
     if (SatanController.CurrentPlayer != null)
     {
         Pushpin pin = new Pushpin()
         {
             Text = "Me"
         };
         BingMap.Children.Add(pin);
         MapLayer.SetPosition(pin, SatanController.CurrentPlayer.Location);
         //Set view
         if (SpearHandler.State == GameState.Idle)
         {
             if (BingMap.ZoomLevel < 15.0f)
             {
                 BingMap.SetView(SatanController.CurrentPlayer.Location, 15.0f);
             }
             else
             {
                 BingMap.SetView(SatanController.CurrentPlayer.Location, BingMap.ZoomLevel);
             }
         }
     }
     //Direction pin
     if (SatanController.DirectionLocation != null)
     {
         Pushpin pin = new Pushpin
         {
             Name = "Direction_Pin"
         };
         pin.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 0, 255));
         BingMap.Children.Add(pin);
         MapLayer.SetPosition(pin, SatanController.DirectionLocation);
     }
     //Spear (if available) also handles focus
     if ((SpearHandler.Gungnir != null) && (!SpearHandler.Gungnir.Available))
     {
         Pushpin pin = new Pushpin()
         {
             Text = "Spear"
         };
         pin.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 125, 125, 0));
         BingMap.Children.Add(pin);
         MapLayer.SetPosition(pin, SpearHandler.Gungnir.Location);
         //Set view
         if (!(SpearHandler.State == GameState.Retrieving))
         {
             if (BingMap.ZoomLevel < 15.0f)
             {
                 BingMap.SetView(SpearHandler.Gungnir.Location, 15.0f);
             }
             else
             {
                 BingMap.SetView(SpearHandler.Gungnir.Location, BingMap.ZoomLevel);
             }
         }
     }
 }