示例#1
0
 public void setPosition(Point point)
 {
     imageLayer.Children.Remove(image);
     imageLayer.AddChild(image, new GeoCoordinate(point.X, point.Y), PositionOrigin.Center);
     X = point.X;
     Y = point.Y;
 }
示例#2
0
        private void InitCar()
        {
            double CarSize      = 50;
            string strImagePath = "/BaseMap;component/image/vehicle.png";
            //string strImagePath = "http://soulsolutions.com.au/Images/pin.png";
            var iconSpec3 = new CustomIconSpecification()
            {
                IconUri    = new Uri(strImagePath, UriKind.RelativeOrAbsolute),
                Width      = CarSize,
                Height     = CarSize,
                IconOffset = new System.Windows.Point(-CarSize / 2, -CarSize / 2),//getIconOffset(iRotateTr),
                //TextContent = ClientStatic.GetIconLblText(initData.CarNo),
                TextOffet = new System.Windows.Point(-15, -46),
                //FontSize = ClientStatic.LableFontSize,
                //TextColor = ClientStatic.CarIconLblColorSCB,
                RotateTr = 0
            };
            var pin = new CustomPushpin
            {
                IconSpecification = iconSpec3,
                Location          = new Location(31.6, 120.3),
                MapInstance       = ctlMap,
                Name = "car",
            };

            carml.AddChild(pin);

            var dp = new DraggablePushpin {
                Location = new Location(31.6, 120.3), Name = "drapcar"
            };

            carml.AddChild(dp, dp.Location);
        }
示例#3
0
 void mapClear()
 {
     layer.Children.Clear();
     pin_Acquirer = new Image()
     {
         Source = new BitmapImage(new Uri("/Image_Acquirer/man.png", UriKind.Relative))
     };
     pin_Acquirer.Width  = 40;
     pin_Acquirer.Height = 50;
     layer.AddChild(pin_Acquirer, new GeoCoordinate((double)vm.acquirerInfo.Latitude, (double)vm.acquirerInfo.Longitude));
     list_Pin.Add(pin_Acquirer);
     map.SetView(new GeoCoordinate((double)vm.acquirerInfo.Latitude, (double)vm.acquirerInfo.Longitude), 16);
 }
        private Pin AddGeoPin(Location location, string tooltip, Color color, double opacity, Geocache geocache)
        {
            var pin = new Pin();

            pin.Cursor     = Cursors.Hand;
            pin.Background = new SolidColorBrush(color);
            pin.Geocache   = geocache;
            pin.Opacity    = opacity;
            pin.Tag        = geocache;
            ToolTipService.SetToolTip(pin, tooltip);
            ToolTipService.SetInitialShowDelay(pin, 0);
            layer.AddChild(pin, new Location(location.Latitude, location.Longitude));
            return(pin);
        }
示例#5
0
        public void AddPointOnMap()
        {
            LocationCollection LC = new LocationCollection();

            foreach (GeographiCoordinates info in gcSet)
            {
                Pushpin   pi = new Pushpin();
                TextBlock tb = new TextBlock();
                tb.Text       = info.placeName;
                tb.Foreground = new SolidColorBrush(Colors.White);
                Location local = new Location(info.latitude, info.longitude);
                LC.Add(local);
                pi.Location   = local;
                pi.Name       = info.placeName;
                pi.Background = new SolidColorBrush(Colors.Blue);
                pushpinLayer.Children.Add(pi);
                toolstipLayer.AddChild(tb, local);
            }
            Main.GeographiCoordinates cgc = new Main.GeographiCoordinates();
            cgc = Main.getGeographiCoordinatesCurrent();
            Location  localCurrent = new Location(cgc.latitude, cgc.longitude);
            Pushpin   piCurrent    = new Pushpin();
            TextBlock tbCurrent    = new TextBlock();

            tbCurrent.Text       = "当前位置";
            tbCurrent.Foreground = new SolidColorBrush(Colors.White);
            piCurrent.Name       = "当前位置";
            piCurrent.Location   = localCurrent;
            pushpinLayer.Children.Add(piCurrent);
            toolstipLayer.AddChild(tbCurrent, localCurrent);

            /*MapPolyline polyline = new MapPolyline();
             * polyline.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue);
             * polyline.StrokeThickness = 5;
             * polyline.Opacity = 0.7;
             * polyline.Locations = LC;
             *
             * BusMap.Children.Add(polyline);*/

            /*MapPolygon polygon = new MapPolygon();
             * polygon.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue);
             * polygon.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Green);
             * polygon.StrokeThickness = 5;
             * polygon.Opacity = 0.7;
             * polygon.Locations = new LocationCollection() {
             * new Location(GeographiCoordinates.latitude,GeographiCoordinates.longitude),
             * new Location(GeographiCoordinates.latitude + 10,GeographiCoordinates.longitude +10),
             * new Location(GeographiCoordinates.latitude -10,GeographiCoordinates.longitude -10),
             * };*/
        }
示例#6
0
        void client_getAllUserCompleted(object sender, getAllUserCompletedEventArgs e)
        {
            //MapLayer layer = new MapLayer();
            //map.Children.Add(layer);
            foreach (User item in e.Result)
            {
                //Pushpin pin = new Pushpin();
                //pin.Location = new GeoCoordinate(item.Latitude,item.Longitude);
                //pin.Content = item.UserName;
                //pin.Tag = item.Id;
                //pin.DataContext = item;
                //layer.AddChild(pin, pin.Location);
                //pin.MouseLeftButtonDown += new MouseButtonEventHandler(pin_MouseLeftButtonDown);
                Image pin = new Image()
                {
                    Source = new BitmapImage(new Uri("Images/pin.png", UriKind.Relative))
                };
                pin.Width       = 35;
                pin.Height      = 35;
                pin.Tag         = item.Id;
                pin.DataContext = item;

                layer.AddChild(pin, new GeoCoordinate(item.Latitude, item.Longitude));
                pin.MouseLeftButtonDown += new MouseButtonEventHandler(pin_MouseLeftButtonDown);

                pin.DoubleTap += new EventHandler <System.Windows.Input.GestureEventArgs>(pin_DoubleTap);
                pushpinList.Add(pin);
            }
            map.SetView(new GeoCoordinate(e.Result[0].Latitude, e.Result[0].Longitude), 10);
            userList = e.Result.ToList <User>();
        }
示例#7
0
        private void PlotConnections(List <TraceRouteInfo> connections)
        {
            _map.Children.Clear();
            CurrentConnections = connections;


            foreach (var connection in connections)
            {
                if (connection.DestinationCity != null && connection.DestinationCity.Location != null && connection.DestinationCity.Location.HasCoordinates)
                {
                    Pushpin pin = new Pushpin
                    {
                        Location = new Location(connection.DestinationCity.Location.Latitude.Value, connection.DestinationCity.Location.Longitude.Value)
                    };



                    _pinLayer.AddChild(new TextBox()
                    {
                        Text = $"'{connection.SourceName}'\r\nto\r\n'{connection.DestinationCity.City}' ({connection.DestinationName})\r\n[{connection.Status}]"
                    }, pin.Location);
                    // Adds the pushpin to the map.
                    _map.Children.Add(pin);
                }
                else
                {
                    //unknown city
                    Debug.WriteLine($"Unknown location for IP address {connection.SourceIpAddress}");
                }
            }
        }
示例#8
0
        public SelectDestination()
        {
            InitializeComponent();
            street.Visibility = Visibility.Visible;
            (ApplicationBar.Buttons[1] as ApplicationBarIconButton).IsEnabled = true;
              
            GeoCoordinate geo = new GeoCoordinate();
            geo = MainPage.bookingData.current_location;
            googlemap.Center = geo;
            googlemap.ZoomLevel = 16;

            zzoom.IsEnabled = true;
            positionLoaded = true;

            Microsoft.Phone.Controls.Maps.Pushpin new_pushpin = new Microsoft.Phone.Controls.Maps.Pushpin();
            new_pushpin.Location = geo;

            pushPinCurrentLocation = new MapLayer();

            new_pushpin.Content = "Current Location:\n ";
            new_pushpin.Content += MainPage.bookingData.current_location_address;
            new_pushpin.Visibility = Visibility.Visible;

            googlemap.Children.Add(pushPinCurrentLocation);
            pushPinCurrentLocation.AddChild(new_pushpin, geo, PositionOrigin.BottomLeft);

            
                if (MainPage.bookingData.isDesSet == true)
                {
                    AddressMapping();
                }

 
            
        }
示例#9
0
        /// <summary>
        /// Pushpin clicked
        /// </summary>
        /// <param name="sender">Pushpin</param>
        /// <param name="e">N/A</param>
        private void PinClicked(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Pushpin  p = sender as Pushpin;
            BaseInfo m = (BaseInfo)p.Tag;

            border = InfoBlock.Build(m);

            if (maplayer.Children.Count > 0)
            {
                ResetMapLayer();
            }
            else
            {
                ResetMapLayer();
                maplayer.AddChild(border, p.Location, new Point(10, 10));
            }

            // Remove the border/textblock from the maplayer
            void ResetMapLayer()
            {
                if (border.Parent != null)
                {
                    MapLayer parent = border.Parent as MapLayer;
                    if (parent.Children.Contains(border))
                    {
                        parent.Children.Clear();
                    }
                }
            }
        }
示例#10
0
        private void addImageToMap(object sender, RoutedEventArgs e)
        {
            List <UIElement> lstMapLayer = CustomerSiteMap.Children.Cast <UIElement>().ToList();

            for (int i = 0; i < lstMapLayer.Count; i++)
            {
                if (lstMapLayer[i].GetType().ToString() == "Microsoft.Maps.MapControl.WPF.MapLayer")
                {
                    CustomerSiteMap.Children.Remove(lstMapLayer[i]);
                }
            }
            CustomerSiteMap.UpdateLayout();

            MapLayer imageLayer = new MapLayer();


            Image image = new Image();

            image.Height = 50;
            image.Width  = 50;
            //Define the URI location of the image
            BitmapImage myBitmapImage = new BitmapImage();

            myBitmapImage.BeginInit();

            myBitmapImage.UriSource = new Uri("http://www.iconsdb.com/icons/preview/red/marker-xxl.png");
            // To save significant application memory, set the DecodePixelWidth or
            // DecodePixelHeight of the BitmapImage value of the image source to the desired
            // height or width of the rendered image. If you don't do this, the application will
            // cache the image as though it were rendered as its normal size rather then just
            // the size that is displayed.
            // Note: In order to preserve aspect ratio, set DecodePixelWidth
            // or DecodePixelHeight but not both.
            //Define the image display properties
            myBitmapImage.DecodePixelHeight = 50;
            myBitmapImage.EndInit();
            image.Source  = myBitmapImage;
            image.Opacity = 0.6;
            image.Stretch = System.Windows.Media.Stretch.None;

            //The map location to place the image at
            Location location = new Location()
            {
                Latitude = Convert.ToDouble(objCustomerLocationModel.Location.Latitude), Longitude = Convert.ToDouble(objCustomerLocationModel.Location.Longitude)
            };
            //{ Latitude =Convert.ToDouble(objCustomerLocationModel.Location.Latitude), Longitude =Convert.ToDouble(objCustomerLocationModel.Location.Longitude) };
            // Location location = new Location() { Latitude = 26.922070, Longitude = 75.778885 };
            //Location location = new Location() { Latitude = 23.424076, Longitude = 53.847818 };
            //Location location = new Location() { Latitude = 33.93911, Longitude = 67.709953 };

            //Center the image around the location specified
            PositionOrigin position = PositionOrigin.Center;

            //Add the image to the defined map layer
            imageLayer.AddChild(image, location, position);
            //Add the image layer to the map
            CustomerSiteMap.Children.Add(imageLayer);
            CustomerSiteMap.ZoomLevel = 2;
            CustomerSiteMap.BringIntoView();
        }
示例#11
0
        public static void AddImageToMap(float latitude, float longitude)
        {
            MapLayer imageLayer = new MapLayer();


            var image = new Image();

            image.Height = 16;
            //Define the URI location of the image
            var myBitmapImage = new BitmapImage();

            myBitmapImage.BeginInit();
            myBitmapImage.UriSource         = new Uri(@"C:\users\shadow\desktop\plane.png");
            myBitmapImage.DecodePixelHeight = 16;
            myBitmapImage.EndInit();
            image.Source = myBitmapImage;
            //image.Opacity = 0.6;
            image.Stretch = Stretch.None;

            image.MouseDown += Image_PreviewMouseDown;

            //The map location to place the image at
            var location = new Location()
            {
                Latitude = latitude, Longitude = longitude
            };
            //Center the image around the location specified
            var position = PositionOrigin.Center;

            //Add the image to the defined map layer
            imageLayer.AddChild(image, location, position);
            //Add the image layer to the map
            Map.Children.Add(imageLayer);
        }
示例#12
0
        private void AddVertexPin(Vertex v)
        {
            //Pushpin pushpin = new Pushpin();
            //pushpin.Style = (Style)(Application.Current.Resources["PushpinStyle"]);

            Image pushpin = MarkerConfig.CreateImage(v);

            pushpin.Tap +=
                (object sender, GestureEventArgs e) =>
            {
                e.Handled = true;

                mWebMapCommon.onTap(v);     //updates the title

                //Navigates to the possibilities
                StringBuilder sb = new StringBuilder();
                sb.Append(Globals.XamlUri_OfflineOnTapAction);
                sb.Append("?title=");
                sb.Append(this.ApplicationTitle.Text);
                this.NavigationService.Navigate(new Uri(sb.ToString(), UriKind.Relative));
            };
            //pushpin.MouseLeftButtonUp += new MouseButtonEventHandler(pushpin_MouseLeftButtonUp);
            AbsoluteLocation pos = v.AbsoluteLocations.First();

            mapLayerVertices.AddChild(pushpin, new GeoCoordinate((double)pos.latitude, (double)pos.longitude), PositionOrigin.BottomCenter);
        }
示例#13
0
        public MainWindow()
        {
            InitializeComponent();

            //mMap.Focus(); // Control with keyBoard
            //mMap.Mode = new AerialMode(true); // AerialMode with Lables
            //myMap.AnimationLevel = AnimationLevel.None;



            Location rambam = new Location(32.83314073512528, 34.985717330983555);
            Location shani  = new Location(31.876640708011877, 34.81796609362201);


            Pushpin pushpin = new Pushpin();

            pushpin.Location = rambam;
            pushpin.ToolTip  = "Sapir";


            MapLayer    layerPush = new MapLayer();
            Image       image     = new Image();
            BitmapImage bit       = new BitmapImage(new Uri(@"d:\Visual Studio\C#\Apps\Bing\Bing\Media\pushRed2.png"));

            image.Source = bit;
            image.Width  = 50;
            image.Height = 50;
            PositionOrigin position = PositionOrigin.TopCenter;

            layerPush.AddChild(image, shani, position);
            myMap.Children.Add(layerPush);
            myMap.Children.Add(pushpin);

            myMap.SetView(rambam, 14);
        }
示例#14
0
        public MainWindow()
        {
            this.DataContext = this;
            Topmost          = true;

            InitializeComponent();
            handle       = new WindowInteropHelper(this).EnsureHandle(); // Get handle of main WPF Window
            handleSource = HwndSource.FromHwnd(handle);                  // Get source of handle in order to add event handlers to it
            handleSource.AddHook(HandleSimConnectEvents);

            SetButtons(true, false, false);

            DispatcherTimer timer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(1)
            };

            timer.Tick += UpdatePosition;
            timer.Start();

            PlaneIconImage.Height  = 48;
            PlaneIconImage.Width   = 48;
            PlaneIconImage.Source  = new BitmapImage(planeIcon);
            PlaneIconImage.Stretch = System.Windows.Media.Stretch.None;

            PlaneIconImage.HorizontalAlignment = HorizontalAlignment.Center;
            PlaneIconImage.VerticalAlignment   = VerticalAlignment.Center;

            Location       planeIconLocation = mapCenter;
            PositionOrigin planeIconPosition = PositionOrigin.Center;

            ImageLayer.AddChild(PlaneIconImage, planeIconLocation, planeIconPosition);
            myMap.Children.Add(ImageLayer);
        }
示例#15
0
        private void MapWithPolygon_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            e.Handled = true;
            // Creates a location for a single polygon point and adds it to
            // the polygon's point location list.
            Point mousePosition = e.GetPosition(this);
            //Convert the mouse coordinates to a location on the map
            Location polygonPointLocation = MapWithPolygon.ViewportPointToLocation(mousePosition);

            newPolygon.Locations.Add(polygonPointLocation);

            // A visual representation of a polygon point.
            Rectangle r = new Rectangle();

            r.Fill            = new SolidColorBrush(Colors.Red);
            r.Stroke          = new SolidColorBrush(Colors.Yellow);
            r.StrokeThickness = 1;
            r.Width           = 8;
            r.Height          = 8;
            Pushpin pin = new Pushpin();

            pin.Location = polygonPointLocation;

            // Adds the pushpin to the map.
            polygonPointLayer.Children.Add(pin);
            // Adds a small square where the user clicked, to mark the polygon point.
            polygonPointLayer.AddChild(r, polygonPointLocation);
            //Set focus back to the map so that +/- work for zoom in/out
            MapWithPolygon.Focus();
        }
示例#16
0
        void MapWithEvents_MouseLeftButtonDown(object sender, MouseEventArgs e)
        {
            // Updates the count of mouse pans.
            ShowEvent("MapWithEvents_MouseLeftButtonDown");

            if (this.isShiftDown)
            {
                this.isMouseDown = true;
                e.Handled        = true;

                // Creates a location for a single polygon point and adds it to
                // the polygon's point location list.
                this.polygonStartPoint = e.GetPosition(this.MyMap);

                //Convert the mouse coordinates to a location on the map
                Location polygonPointLocation = MyMap.ViewportPointToLocation(this.polygonStartPoint);
                mapPolygon.Locations.Add(polygonPointLocation);

                // A visual representation of a polygon point.
                Rectangle r = new Rectangle();
                r.Fill            = new SolidColorBrush(Colors.Red);
                r.Stroke          = new SolidColorBrush(Colors.Yellow);
                r.StrokeThickness = 1;
                r.Width           = 8;
                r.Height          = 8;

                // Adds a small square where the user clicked, to mark the polygon point.
                polygonPointLayer.AddChild(r, polygonPointLocation);
                //Set focus back to the map so that +/- work for zoom in/out
                MyMap.Focus();
            }
        }
示例#17
0
        public static void ShowDistance(this Map MyMap, MapPolyline mapPolyline)
        {
            var    geo1 = new GeoCoordinate();
            var    geo2 = new GeoCoordinate();
            int    i    = 0;
            double km   = 0;

            foreach (var location in mapPolyline.Locations)
            {
                if (i < 1)
                {
                    geo2.Latitude  = location.Latitude;
                    geo2.Longitude = location.Longitude;
                }
                else
                {
                    geo1.Latitude  = geo2.Latitude;
                    geo1.Longitude = geo2.Longitude;
                    geo2.Latitude  = location.Latitude;
                    geo2.Longitude = location.Longitude;
                    km            += geo1.GetDistanceTo(geo2);
                    var child = new MapLayer();
                    child.AddChild(new TextBlock()
                    {
                        Text = String.Format("{0:0.##}", km / 1000) + "km", Foreground = Brushes.Red
                    }, location);
                    MyMap.Children.Add(child);
                }
                i++;
            }
        }
示例#18
0
        void drawLabel(String label, Location Spot, String requestType)
        {
            try
            {
                Label customLabel = new Label();

                String dog = new String((char)count, 4);
                dog = dog + "A";
                customLabel.Name    = dog;
                customLabel.Content = label;

                if (requestType == "A")
                {
                    customLabel.Foreground = yellowBrush;
                }
                else if (requestType == "G")
                {
                    customLabel.Foreground = greenBrush;
                }
                else
                {
                    customLabel.Foreground = redBrush;
                }
                customLabel.FontSize = 24;
                labelLayer.AddChild(customLabel, Spot);
            }
            catch (Exception mapped)
            {
                Console.WriteLine("labelLayer failure. " + mapped);
            }
        }
        private void PositionAndRotateImage(GeoCoordinate position, double angle)
        {
            try
            {
                MapLayer.Children.Clear();
                AppGrid.Children.Remove(CompassImage);
                CompassImage.RenderTransform = new RotateTransform {
                    Angle = angle
                };
                CompassImage.HorizontalAlignment = HorizontalAlignment.Right;
                CompassImage.VerticalAlignment   = VerticalAlignment.Top;
                AppGrid.Children.Add(CompassImage);
                Grid.SetRow(CompassImage, 1);

                arrow.RenderTransform = new RotateTransform {
                    Angle = angle
                };
                MapLayer.AddChild(arrow, position, PositionOrigin.Center);

                /*foreach (GeoCoordinate point in traceLine.Locations)
                 *  MapLayer.Children.Add(new Pushpin() { Location = point });*/
                //MapLayer.Children.Add(traceLine);
            }
            catch (Exception exp) { }
        }
示例#20
0
        private void BtnCalc_Click(object sender, RoutedEventArgs e)
        {
            string myFile = @"c:\ProgramData\Adobe\ARM\Reader_15.008.20082\Visual Studio\C#\Bing\Gpx\1_בדצמ׳_2020_22_02_01.gpx";


            ds.ReadXml(myFile);

            myTbl = ds.Tables["trkpt"];

            var locs = new LocationCollection();

            for (int i = 0; i < myTbl.Rows.Count; i = i + 10)
            {
                locs.Add(new Microsoft.Maps.MapControl.WPF.Location(Convert.ToDouble(myTbl.Rows[i]["lat"]), Convert.ToDouble(myTbl.Rows[i]["lon"])));
            }

            var routeLine = new MapPolyline()
            {
                Locations       = locs,
                Stroke          = new SolidColorBrush(Colors.Blue),
                StrokeThickness = 5
            };

            mMap.Children.Add(routeLine);

            Microsoft.Maps.MapControl.WPF.Location start = new Microsoft.Maps.MapControl.WPF.Location(locs[locs.Count - 1].Latitude, locs[locs.Count - 1].Longitude);
            Microsoft.Maps.MapControl.WPF.Location end   = new Microsoft.Maps.MapControl.WPF.Location(locs[0].Latitude, locs[0].Longitude);

            Pushpin pushpinStart = new Pushpin();

            pushpinStart.Location = start;

            Pushpin pushpinEnd = new Pushpin();

            pushpinEnd.Location = end;

            //mMap.Children.Add(pushpinStart);
            mMap.Children.Add(pushpinEnd);

            Image image = new Image();

            BitmapImage bitmap = new BitmapImage(new Uri("pack://application:,,,/Bing;component/Resources/pushRed2.png"));

            image.Source = bitmap;
            image.Width  = 50;
            image.Height = 50;

            MapLayer layer = new MapLayer();

            PositionOrigin position = PositionOrigin.BottomCenter;

            layer.AddChild(image, start, position);

            mMap.Children.Add(layer);

            mMap.SetView(start, 10);
            mMap.Center = start;
        }
示例#21
0
        private void AgregarPinMapaPorBusqueda(Location pinLocation, object localidadSeleccionada)
        {
            // The pushpin to add to the map.
            ZMXUC_MapaPin pin = new ZMXUC_MapaPin();

            pin.ZMX_Color    = panelBusqueda.ZMX_Color;
            pin.ZMX_Location = pinLocation;

            if (panel_seBuscaOrigen)
            {
                pinOrigen            = pin;
                pinOrigen.ZMX_Height = tamOrigen;
                pinOrigen.ZMX_Icono  = Iconos.IconAwesomeSIZ.AwesomeIcons.fa_circle_o;
                pin_layer.AddChild(pin, pin.ZMX_Location);

                zmx_LocalidadOrigen = localidadSeleccionada;

                PropertyInfo piOrigen = ZMX_LocalidadOrigen.GetType().GetProperty(ZMX_PropiedadLocalidadNombre, BindingFlags.Instance | BindingFlags.Public);
                panelBusqueda.ZMX_SetLocalidadOrigen(piOrigen.GetValue(ZMX_LocalidadOrigen).ToString());

                ZMX_CambioUbicacionOrigen(this, ConvertCoordenadasLocationToString(pin.ZMX_Location), localidadSeleccionada);
            }
            else
            {
                pinDestino = pin;

                zmx_LocalidadDestino = localidadSeleccionada;

                pin_layer.AddChild(pin, pin.ZMX_Location);

                PropertyInfo piDestino = ZMX_LocalidadDestino.GetType().GetProperty(ZMX_PropiedadLocalidadNombre, BindingFlags.Instance | BindingFlags.Public);
                panelBusqueda.ZMX_SetLocalidadDestino(piDestino.GetValue(ZMX_LocalidadDestino).ToString());

                ZMX_CambioUbicacionDestino(this, ConvertCoordenadasLocationToString(pin.ZMX_Location), localidadSeleccionada);
            }

            if (pinOrigen != null && pinDestino != null)
            {
                ZMX_TrazarRutaPorPin();
            }

            panel_esPorBusquedaPanel = false;
        }
        /// <summary>
        /// Opens a map centered on a business with a textblock of information about the business
        /// </summary>
        /// <param name="currentBusiness"></param>
        private void BusinessMap(Business currentBusiness)
        {
            StringBuilder businessText = new StringBuilder();

            businessText.AppendLine(currentBusiness.Name);
            businessText.AppendLine(currentBusiness.Address);
            businessText.AppendLine("Review Count: " + currentBusiness.Reviewcount);
            businessText.AppendLine("Review Rating: " + currentBusiness.Reviewrating);
            businessText.Append("Check-Ins: " + currentBusiness.Numcheckins);
            SolidColorBrush background = new SolidColorBrush(Colors.Violet)
            {
                Opacity = 0.75
            };

            TextBlock businessInformation = new TextBlock
            {
                Text = businessText.ToString(),
                VerticalAlignment   = VerticalAlignment.Stretch,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Padding             = new Thickness(5),
                Background          = background,
                FontSize            = 16,
                FontWeight          = FontWeights.UltraBold
            };
            Border border = new Border
            {
                BorderBrush         = Brushes.Black,
                BorderThickness     = new Thickness(5),
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Margin = new Thickness(10, 0, 0, 0),
                Child  = businessInformation
            };

            Location center   = new Location(currentBusiness.Latitude, currentBusiness.Longitude);
            MapLayer mapLayer = new MapLayer();

            mapLayer.AddChild(border, center);

            Pushpin businessPin = new Pushpin
            {
                Location = center
            };

            Map popupMap = new Map
            {
                Center = center,
                Name   = "Business"
            };

            popupMap.Children.Add(businessPin);
            popupMap.Children.Add(mapLayer);

            CreatePopup(popupMap);
        }
示例#23
0
        private Pushpin AddPin(Location location, string tooltip, Color color)
        {
            var pin = new Pushpin();

            pin.Cursor     = Cursors.Hand;
            pin.Background = new SolidColorBrush(color);
            ToolTipService.SetToolTip(pin, tooltip);
            ToolTipService.SetInitialShowDelay(pin, 0);
            layer.AddChild(pin, new Location(location.Latitude, location.Longitude));
            return(pin);
        }
示例#24
0
        private static void AddImagePushPin(string urlicon, double latitude, double longitude, string url, MapLayer layer)
        {
            Pin photoPin = new Pin
            {
                ImageSource = new BitmapImage(new Uri(urlicon, UriKind.RelativeOrAbsolute)),
                MapInstance = (Map)layer.ParentMap
            };

            ToolTip tt = AddToolTip(new Image { Source = new BitmapImage(new Uri(url)) });
            ToolTipService.SetToolTip(photoPin, tt);
            layer.AddChild(photoPin, new Location(latitude, longitude, 0), PositionOrigin.Center);
        }
示例#25
0
        protected override void OnActivate()
        {
            var map   = ((FrameworkElement)GetView()).Descendants().OfType <Map>().SingleOrDefault(x => x.Name == "Location");
            var layer = new MapLayer();

            map.Children.Add(layer);
            layer.AddChild(new Pushpin()
            {
                Background = new SolidColorBrush(Colors.Red), Content = Address
            }, Location);
            base.OnActivate();
        }
示例#26
0
        private void LineMouseEnter(object sender, MouseEventArgs e)
        {
            MapPolyline line  = e.OriginalSource as MapPolyline;
            UIElement   label = line.DataContext as UIElement;

            Point mousePosition = e.GetPosition((IInputElement)sender);

            mousePosition.X += 12;
            mousePosition.Y += 12;

            Location loc = MetroMap.ViewportPointToLocation(mousePosition);

            lineLabelLayer.AddChild(label, loc);
        }
示例#27
0
        public VenuePage()
        {
            InitializeComponent();
            imageLayer = new MapLayer();
            mapArea.Children.Add(imageLayer);

            mapArea.Center = new GeoCoordinate(49.879738, -97.203598);
            Image pinImage = new Image();
            pinImage.Source = new BitmapImage(new Uri("images/prairiedevconpin.png", UriKind.Relative));
            pinImage.Stretch = Stretch.None;
            PositionOrigin origin = PositionOrigin.BottomCenter;

            imageLayer.AddChild(pinImage, mapArea.Center, origin);
        }
        void DetailsMap_TargetViewChanged(object sender, MapEventArgs e)
        {
            GeoCoordinate center = DetailsMap.TargetCenter;

            mapHasMoved = true;

            if (DetailsMap.TargetZoomLevel >= minZoomLevel)
            {
                viewModel.LoadStopsForLocation(center);
            }

#if DEBUG
            cacheRectLayer.Children.Clear();

            int    roundingLevel  = 2;
            int    multiplier     = 3;
            double positiveOffset = (Math.Pow(.1, roundingLevel) * 0.5) / multiplier;
            double negativeOffset = (Math.Pow(.1, roundingLevel) * 0.5) / multiplier;

            double lat = Math.Round(center.Latitude * multiplier, roundingLevel) / multiplier;
            double lon = Math.Round(center.Longitude * multiplier, roundingLevel) / multiplier;

            // Round off the extra decimal places to prevent double precision issues
            // from causing multiple cache entires
            GeoCoordinate roundedLocation = new GeoCoordinate(
                Math.Round(lat, roundingLevel + 1),
                Math.Round(lon, roundingLevel + 1)
                );

            MapPolygon cacheSquare = new MapPolygon();
            cacheSquare.Locations = new LocationCollection();
            cacheSquare.Locations.Add(new GeoCoordinate(roundedLocation.Latitude + positiveOffset, roundedLocation.Longitude + positiveOffset));
            cacheSquare.Locations.Add(new GeoCoordinate(roundedLocation.Latitude - negativeOffset, roundedLocation.Longitude + positiveOffset));
            cacheSquare.Locations.Add(new GeoCoordinate(roundedLocation.Latitude - negativeOffset, roundedLocation.Longitude - negativeOffset));
            cacheSquare.Locations.Add(new GeoCoordinate(roundedLocation.Latitude + positiveOffset, roundedLocation.Longitude - negativeOffset));

            cacheSquare.Stroke          = new SolidColorBrush(Colors.Black);
            cacheSquare.StrokeThickness = 5;

            cacheRectLayer.Children.Add(cacheSquare);

            Pushpin requestCenterPushpin = new Pushpin();
            requestCenterPushpin.Location = roundedLocation;

            cacheRectLayer.Children.Add(requestCenterPushpin);

            CenterControl deadCenter = new CenterControl();
            cacheRectLayer.AddChild(deadCenter, center, PositionOrigin.Center);
#endif
        }
示例#29
0
        private void StopMouseEnter(object sender, MouseEventArgs e)
        {
            Pushpin   stop  = e.Source as Pushpin;
            TextBlock label = stop.DataContext as TextBlock;

            Point position = e.GetPosition(MetroMap);

            position.X += 12;
            position.Y -= 50;

            Location loc = MetroMap.ViewportPointToLocation(position);

            stopLabelLayer.AddChild(label, loc);
        }
示例#30
0
        private void SetupNewWifiSpots() // Goes through every wifi hotspot in the database and adds it to the map
        {
            using (SpeedApplicationDBEntities context = new SpeedApplicationDBEntities())
            {
                foreach (var data in context.WifiData)
                {
                    Pushpin p = new Pushpin();
                    p.Content = data.aanbieder;

                    Location location = new Location((double)data.lat, (double)data.@long);
                    wifiLayer.AddChild(p, location);
                }
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // add a dummy pushbin
            Image pinImage = new Image();

            pinImage.Source  = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Assets/Icons/marker/yes/coffee.png", UriKind.RelativeOrAbsolute));
            pinImage.Width   = 37;
            pinImage.Height  = 37;
            pinImage.Opacity = 1d;
            pinImage.Stretch = System.Windows.Media.Stretch.None;
            PositionOrigin position = PositionOrigin.BottomCenter;

            imageLayer.AddChild(pinImage, map.TargetCenter, position);
        }
示例#32
0
        void ViewModel_StationsSearched(object sender, EventArgs e)
        {
            Progress.IsIndeterminate = false;
            Progress.Visibility      = System.Windows.Visibility.Collapsed;

            AvailabilityToIconValueConverter converter =
                this.Resources["AvailabilityToIconValueConverter"] as AvailabilityToIconValueConverter;

            foreach (Station s in App.ViewModel.Stations)
            {
                string iconName = (string)converter.Convert(s.Availability, null, null, null);
                iconName = iconName.Replace("Menu", "");
                //iconName = iconName.Replace("@2x", "");

                Image pinImage = new Image();
                pinImage.Source  = new System.Windows.Media.Imaging.BitmapImage(new Uri(iconName, UriKind.Relative));
                pinImage.Opacity = 0.8;
                pinImage.Stretch = System.Windows.Media.Stretch.None;
                PositionOrigin position = PositionOrigin.Center;
                pinImage.Tag = s;
                stationsLayer.AddChild(pinImage, s.Coordinate, position);
                pinImage.MouseLeftButtonDown += new MouseButtonEventHandler(pinImage_MouseLeftButtonDown);
            }
        }
示例#33
0
        private void addPointOfInterest(EntityViewModel entity)
        {
            //Add the image to the defined map layer
            if (!images.ContainsKey(entity.Id))
            {
                Image image = new Image();
                image.Height = 50;
                image.Source = entity.Image;

                //Center the image around the location specified
                PositionOrigin position = PositionOrigin.Center;
                layer.AddChild(image, new Location(entity.Latitude, entity.Longitude), position);
                images.Add(entity.Id, image);
            }
        }
示例#34
0
        public void draw(Map map)
        {
            MapLayer imageLayer = new MapLayer();

            Image image = new Image();
            image.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("movie.png", UriKind.Relative));
            image.Opacity = 0.8;
            image.Stretch = System.Windows.Media.Stretch.None;
            image.MouseLeftButtonDown += new MouseButtonEventHandler(image_MouseLeftButtonDown);

            PositionOrigin position = PositionOrigin.Center;

            imageLayer.AddChild(image, location, position);
            map.Children.Add(imageLayer);

            ref_mainMap = map;
        }
示例#35
0
        private void AddLocation()
        {
            MapLayer imageLayer = new MapLayer();

            VenueViewModel venue = DataContext as VenueViewModel;
                    Image image = new Image();
                    //Define the URI location of the image
                    image.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(venue.Icon, UriKind.Absolute));
                    //Define the image display properties
                    image.Opacity = 0.8;
                    image.Stretch = System.Windows.Media.Stretch.None;

                    //Add the image to the defined map layer
                    imageLayer.AddChild(image, venue.Location, PositionOrigin.Center);
                    //Add the image layer to the map

            map.Children.Add(imageLayer);
        }
示例#36
0
        public PlaceEvent()
        {
            InitializeComponent();
            myMap.Focus();

            //Create custom pin for the users location
            Image userLocationPin = new Image();
            userLocationPin.Source = new BitmapImage(new Uri("images/userPin.png", UriKind.Relative));
            ToolTipService.SetToolTip(userLocationPin, "You are here");
            userLocationPin.Width = 20;
            userLocationPin.Height = 20;

            GeoLookup myGeoLookup = new GeoLookup();

            // Get host IP Address
            string myIP = new System.Net.WebClient().DownloadString("http://ipinfo.io/ip");

            // Turn IP Address into geo location lat & long
            myGeoLookup.GetGeo(myIP);

            // Right click to add pin method call
            myMap.MouseRightButtonDown += new MouseButtonEventHandler(Click_AddPins);

            //Wait for page load
            Loaded += onLoad;

            // users current position on map
            myMap.Center = new Location(Convert.ToDouble(myGeoLookup.Latitude), Convert.ToDouble(myGeoLookup.Longitude));
            //myMap.Center = new Location(52.792542056467, -6.14546695770263);

            // Map default zoom level 0-20
            myMap.ZoomLevel = 15;

            // Create new layer to hold pins
            MapLayer pinLayer = new MapLayer();

            //User Pin
            pinLayer.AddChild(userLocationPin, myMap.Center, PositionOrigin.Center);

            // Add pinlayer on top of maplayer
            myMap.Children.Add(pinLayer);
        }
        private void btn_Map_Click(object sender, RoutedEventArgs e)
        {
            sp_Map.Visibility = Visibility.Visible;
            sp_Content.Visibility = Visibility.Collapsed;
            watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
            watcher.Start();
            
            map.SetView(watcher.Position.Location, 14);
            map.Mode = new AerialMode();
            Pin_My = new Image();
            Pin_My = new Image() { Source = new BitmapImage(new Uri("/Image_Acquirer/man.png", UriKind.Relative)) };
            Pin_My.Width = 40;
            Pin_My.Height = 50;
            layer = new MapLayer();
            map.Children.Add(layer);
            layer.AddChild(Pin_My, watcher.Position.Location);
            Pin_My.Tag = watcher.Position.Location;
            map.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(map_Tap);

        }
示例#38
0
        public void draw(Map map){

            MapLayer imageLayer = new MapLayer();

            Image image = new Image();
            Uri uri = new Uri(this.URL);
            image.Source = new System.Windows.Media.Imaging.BitmapImage(uri);

            //Define the image display properties
            image.Opacity = 0.8;
            image.Stretch = System.Windows.Media.Stretch.None;

            //Center the image around the location specified
            PositionOrigin position = PositionOrigin.Center;

            //Add the image to the defined map layer
            imageLayer.AddChild(image, location, position);
            //Add the image layer to the map
            map.Children.Add(imageLayer);
        }
示例#39
0
        private void AddLocations()
        {
            MapLayer imageLayer = new MapLayer();

            foreach (CategoryViewModel category in App.ViewModel.Categories) {
                if (category.Venues == null) continue;
                foreach (VenueViewModel venue in category.Venues) {
                    Image image = new Image();
                    //Define the URI location of the image
                    image.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(venue.Icon, UriKind.Absolute));
                    //Define the image display properties
                    image.Opacity = 0.8;
                    image.Stretch = System.Windows.Media.Stretch.None;

                    //Add the image to the defined map layer
                    imageLayer.AddChild(image, venue.Location, PositionOrigin.Center);
                    //Add the image layer to the map
                }
            }

            Map.Children.Add(imageLayer);
        }
示例#40
0
        private async void Locate_Click(object sender, EventArgs e)
        {
            positionLoaded = false;
           
            Geolocator geolocator = new Geolocator();
            geolocator.DesiredAccuracyInMeters = 10;

            try
            {
                gPos = await geolocator.GetGeopositionAsync(
                    maximumAge: TimeSpan.FromSeconds(5),
                    timeout: TimeSpan.FromSeconds(10)
                    );


                dlat = gPos.Coordinate.Latitude;
                dlong = gPos.Coordinate.Longitude;
                LatitudeTextBlock.Text = "Latitude:  " + gPos.Coordinate.Latitude.ToString("0.000000"); //geoposition.Coordinate.Latitude.ToString("0.00"); //
                LongitudeTextBlock.Text = "Longitude: " + gPos.Coordinate.Longitude.ToString("0.000000");//geoposition.Coordinate.Longitude.ToString("0.00"); //

                //Storing in static variables for access in other pages of app
                Booking.DestinationLat = gPos.Coordinate.Latitude.ToString("0.000000");
                Booking.DestinationLong = gPos.Coordinate.Longitude.ToString("0.000000");
                ReverseGeocodeQuery getAddress = new ReverseGeocodeQuery();
        
                GeoCoordinate geo = new GeoCoordinate();
                geo.Latitude = gPos.Coordinate.Latitude;
                geo.Longitude = gPos.Coordinate.Longitude;
                googlemap.Center = geo;
                googlemap.ZoomLevel = 16;

                string url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + geo.Latitude + "," + geo.Longitude + "&sensor=true";
                var client = new WebClient();

                string response = await client.DownloadStringTaskAsync(new Uri(url));
                JObject root = JObject.Parse(response);

                JArray items = (JArray)root["results"];
                JObject item;
                JToken jtoken;
                item = (JObject)items[0];
                JArray add_comp = (JArray)item["address_components"];
                string address = null;
                string[] add_types = { "street_number", "route", "neighborhood", "locality", "city", "country" };
                foreach (var comp in add_comp)
                {
                    if (add_types.Any(comp["types"].ToString().Contains))
                    {
                        address += comp["long_name"].ToString() + ", ";
                        if (comp["types"].ToString().Contains("city") | comp["types"].ToString().Contains("country"))
                        {
                            address += "\n";
                        }
                    }
                }

                /////////////////////////////////////////////////////////////////////////////////////////
                // Address From Google
                

                /////////////////////////////////////////////////////////////End Google Code

                (ApplicationBar.Buttons[0] as ApplicationBarIconButton).IsEnabled = true;
                (ApplicationBar.Buttons[1] as ApplicationBarIconButton).IsEnabled = true;
                (ApplicationBar.Buttons[2] as ApplicationBarIconButton).IsEnabled = true;
                (ApplicationBar.Buttons[3] as ApplicationBarIconButton).IsEnabled = true;

                zzoom.IsEnabled = true;
                positionLoaded = true;

                Microsoft.Phone.Controls.Maps.Pushpin new_pushpin = new Microsoft.Phone.Controls.Maps.Pushpin();
                new_pushpin.Location = geo;

                googlemap.Children.Remove(pushPinLayer);
                pushPinLayer = new MapLayer();

                
                new_pushpin.Content = address;
                Address.Text = address;
                new_pushpin.Visibility = Visibility.Visible;

                googlemap.Children.Add(pushPinLayer);
                pushPinLayer.AddChild(new_pushpin, geo, PositionOrigin.BottomLeft);

                MainPage.bookingData.set_current_location_attributes(address,geo);
            }
            catch (Exception ex)
            {
                if ((uint)ex.HResult == 0x80004004)
                {
                    // the application does not have the right capability or the location master switch is off
                    MessageBox.Show("location  is disabled in phone settings");
                }
                //else
                {
                    // something else happened acquring the location
                }
            }

        }
示例#41
0
        protected override void OnActivate()
        {
            var map = ((FrameworkElement)GetView()).Descendants().OfType<Map>().SingleOrDefault(x => x.Name == "Location");
            var layer = new MapLayer();

            map.Children.Add(layer);
            layer.AddChild(new Pushpin() { Background = new SolidColorBrush(Colors.Red), Content = Address }, Location);
            base.OnActivate();
        }
示例#42
0
        private async void mapOnhold(object sender, System.Windows.Input.GestureEventArgs e)
        {
            googlemap.Children.Remove(pushPinLayer);
            pushPinLayer = new MapLayer();

            try
            {
                Point p = e.GetPosition(this.googlemap);
                GeoCoordinate geo = new GeoCoordinate();
                geo = googlemap.ViewportPointToLocation(p);

                Microsoft.Phone.Controls.Maps.Pushpin new_pushpin = new Microsoft.Phone.Controls.Maps.Pushpin();
                new_pushpin.Location = geo;

                // Storing in static variables
                //Booking.SourceLat = geo.Latitude.ToString("0.000000");
                //Booking.SourceLong = geo.Longitude.ToString("0.000000");

                // Translating geocoordinates into address
                string url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + geo.Latitude + "," + geo.Longitude + "&sensor=true";
                var client = new WebClient();

                string response = await client.DownloadStringTaskAsync(new Uri(url));
                JObject root = JObject.Parse(response);

                JArray items = (JArray)root["results"];
                JObject item;
                JToken jtoken;
                item = (JObject)items[0];
                JArray add_comp = (JArray)item["address_components"];
                string address = null;
                string[] add_types = { "street_number", "route", "neighborhood", "locality", "city", "country" };
                foreach (var comp in add_comp)
                {
                    if (add_types.Any(comp["types"].ToString().Contains))
                    {
                        address += comp["long_name"].ToString() + ", ";
                        if (comp["types"].ToString().Contains("city") | comp["types"].ToString().Contains("country"))
                        {
                            address += "\n";
                        }
                    }
                }

                new_pushpin.Content = address;
                Address.Text = address;
                new_pushpin.Visibility = Visibility.Visible;

                // gPos.Coordinate.Latitude = geo.Latitude;
                // gPos.Coordinate.Longitude=geo.Longitude;
                googlemap.Children.Add(pushPinLayer);
                pushPinLayer.AddChild(new_pushpin, geo, PositionOrigin.BottomLeft);
               //MainPage.bookingData.set_current_location_attributes(address, geo);

                LatitudeTextBlock.Text = "Latitude:  " + geo.Latitude.ToString("0.000000"); //geoposition.Coordinate.Latitude.ToString("0.00"); //
                LongitudeTextBlock.Text = "Longitude: " + geo.Longitude.ToString("0.000000");//geoposition.Coordinate.Longitude.ToString("0.00"); //

                //MessageBox.Show(gPos.Coordinate.Latitude.ToString("0.000000"));
                //MessageBox.Show(gPos.Coordinate.Longitude.ToString("0.000000"));
                using (var store = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    if (store.FileExists("track.txt"))
                    {
                        IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
                        storage.DeleteFile("track.txt");
                    }

                }

                IsolatedStorageFile fileStorage = IsolatedStorageFile.GetUserStoreForApplication();
                StreamWriter Writer = new StreamWriter(new IsolatedStorageFileStream("track.txt", FileMode.OpenOrCreate, fileStorage));
                Writer.WriteLine(geo.Latitude.ToString("0.000000"));
                Writer.WriteLine(geo.Longitude.ToString("0.000000"));

                //MessageBox.Show(gPos.Coordinate.Latitude.ToString("0.000000"));
                //MessageBox.Show(gPos.Coordinate.Longitude.ToString("0.000000"));
                Writer.Close();

            }
            catch (Exception ed)
            {
                MessageBox.Show("Unable to Get Coordinates of Current Point");
            }
        }
        void routeService_CalculateRouteCompleted(object sender, CalculateRouteCompletedEventArgs e)
        {
            RouteResponse response = e.Result;
            if ((response.ResponseSummary.StatusCode == Panda.Phone.Publisher.RouteServiceReference.ResponseStatusCode.Success) && (response.Result.Legs.Count != 0))
            {
                Color color = Colors.Blue;
                // SolidColorBrush brush = new SolidColorBrush(color);
                SolidColorBrush brush = new SolidColorBrush(new Color() { R = 6, G = 128, B = 67, A = 255 });
                MapPolyline line = new MapPolyline();
                line.Locations = new LocationCollection();
                line.Opacity = 0.6;
                line.StrokeThickness = 10;
                line.Stroke = brush;
                //DispatcherTimer timer = new DispatcherTimer();
                //timer.Interval = TimeSpan.FromMilliseconds(200);
                //timer.Tick += new EventHandler(timer_Tick);
                //timer.Start();
                MapLayer layer = new MapLayer();
                layer.Children.Add(line);
                map.Children.Add(layer);
                foreach (Location l in response.Result.RoutePath.Points)
                {
                    line.Locations.Add(l);
                }

                //foreach (GeocodeResult r in Georesults)
                //{
                //    Ellipse ellipse = new Ellipse();
                //    ellipse.Height = 10;
                //    ellipse.Width = 10;
                //    ellipse.Fill = new SolidColorBrush(Colors.Red);
                //    Location location = new Location()
                //    {
                //        Latitude = r.Locations[0].Latitude,
                //        Longitude = r.Locations[0].Longitude
                //    };
                //    layer.AddChild(ellipse, location);
                //}

                foreach (UserModel user in list_User_Choosed)
                {
                    Ellipse ellipse = new Ellipse();
                    ellipse.Height = 10;
                    ellipse.Width = 10;
                    ellipse.Fill = new SolidColorBrush(new Color() { A = 0 });
                    Location location = new Location()
                    {
                        Latitude = user.Latitude,
                        Longitude = user.Longitude
                    };
                    layer.AddChild(ellipse, location);
                }
                //GeoCoordinate p = new GeoCoordinate(Georesults[1].Locations[0].Latitude, Georesults[1].Locations[0].Longitude);
                // var routeModel = new RouteModel(e.Result.Result.RoutePath.Points);
                //  LocationRect rect = LocationRect.CreateLocationRect(routeModel.Locations);

                // Set the map view using the rectangle which bounds the rendered route.
                // map.SetView(p, 8);
            }

        }
示例#44
0
        public FindEvent(string eventType)
        {
            InitializeComponent();
            //Create custom pin for the users location
            Image userLocationPin = new Image();
            userLocationPin.Source = new BitmapImage(new Uri("images/userPin.png", UriKind.Relative));
            ToolTipService.SetToolTip(userLocationPin, "You are here");
            userLocationPin.Width = 20;
            userLocationPin.Height = 20;

            //Get host IP Address
            string myIP = new System.Net.WebClient().DownloadString("http://ipinfo.io/ip");

            //Turn IP Address into geo location lat & long
            GeoLookup myGeoLookup = new GeoLookup();
            myGeoLookup.GetGeo(myIP);
            userLat = Convert.ToDouble(myGeoLookup.Latitude);
            userLong = Convert.ToDouble(myGeoLookup.Longitude);

            //Testing stuff
            //Console.WriteLine("\nIPAddress: " + myIP + "Latitude: {0} \nLongitude {1}", myGeoLookup.Latitude, myGeoLookup.Longitude);
            //Console.WriteLine("Country {0} \ncity {1} \nregion: {2} \nipaddress: {3}", myGeoLookup.CountryName, myGeoLookup.CityName, myGeoLookup.RegionName, myGeoLookup.IpAddress);

            //Disable drag function
            myMap.MouseLeftButtonDown += Disable_Drag;

            //Disable zoom function
            myMap.MouseDoubleClick += Disable_Zoom;

            //Disable scroll function
            myMap.MouseWheel += Disable_MouseWheel;

            //Wait for page to load
            Loaded += onLoad;

            // Users current position on map
            myMap.Center = new Location(userLat, userLong);

            // Map default zoom level 0-20
            myMap.ZoomLevel = 15;

            // Create new layer to hold pins
            MapLayer pinLayer = new MapLayer();

            //User Pin
            pinLayer.AddChild(userLocationPin, myMap.Center, PositionOrigin.Center);

            try
            {
                //Online Connection Via FreeMySqlHosting.net
                String myConnection = "SERVER=sql2.freemysqlhosting.net;PORT=3306;DATABASE=sql292370;UID=sql292370;password=gA4*tV5%;";

                using (MySqlConnection myConn = new MySqlConnection(myConnection))
                {
                    myConn.Open();
                    string command = "";

                    // Event filter
                    switch (eventType)
                    {
                        case "default":
                            {
                                command = ("SELECT * FROM sql292370.Events WHERE (latitude BETWEEN " + userLat + " - .009 AND " + userLat + " + .009) && (longitude BETWEEN " + userLong + " - .012 AND " + userLong + " + .012) && (eventdate = CAST(NOW() AS DATE)) AND (CAST(NOW() AS TIME) < endtime) && (eventReport < 25);");
                                break;
                            }
                        case "sport":
                            {
                                command = ("SELECT * FROM sql292370.Events WHERE (latitude BETWEEN " + userLat + " - .009 AND " + userLat + " + .009) && (longitude BETWEEN " + userLong + " - .012 AND " + userLong + " + .012) && (eventdate = CAST(NOW() AS DATE)) AND (CAST(NOW() AS TIME) < endtime) && (eventGroup = 'Sport') && (eventReport < 25);");
                                break;
                            }

                        case "food":
                            {
                                command = ("SELECT * FROM sql292370.Events WHERE (latitude BETWEEN " + userLat + " - .009 AND " + userLat + " + .009) && (longitude BETWEEN " + userLong + " - .012 AND " + userLong + " + .012) && (eventdate = CAST(NOW() AS DATE)) AND (CAST(NOW() AS TIME) < endtime) && (eventGroup = 'Food') && (eventReport < 25);");
                                break;
                            }

                        case "other":
                            {
                                command = ("SELECT * FROM sql292370.Events WHERE (latitude BETWEEN " + userLat + " - .009 AND " + userLat + " + .009) && (longitude BETWEEN " + userLong + " - .012 AND " + userLong + " + .012) && (eventdate = CAST(NOW() AS DATE)) AND (CAST(NOW() AS TIME) < endtime) && (eventGroup = 'Other') && (eventReport < 25);");
                                break;
                            }
                        case "entertainment":
                            {
                                command = ("SELECT * FROM sql292370.Events WHERE (latitude BETWEEN " + userLat + " - .009 AND " + userLat + " + .009) && (longitude BETWEEN " + userLong + " - .012 AND " + userLong + " + .012) && (eventdate = CAST(NOW() AS DATE)) AND (CAST(NOW() AS TIME) < endtime) && (eventGroup = 'Entertainment') && (eventReport < 25);");
                                break;
                            }
                    }

                    MySqlCommand getEvents = new MySqlCommand(command, myConn);

                    using (MySqlDataReader DR = getEvents.ExecuteReader())
                    {

                        while (DR.Read())
                        {
                            //Create new pin
                            Pushpin pin = new Pushpin();

                            //set pin colour (based on group)
                            switch (DR.GetValue(12).ToString())
                            {
                                case "Sport":
                                    {

                                        pin.Background = new SolidColorBrush(Color.FromArgb(255, 77, 210, 0));
                                        break;
                                    }

                                case "Food":
                                    {
                                        pin.Background = new SolidColorBrush(Color.FromArgb(255, 255, 0, 17));
                                        break;
                                    }

                                case "Other":
                                    {
                                        pin.Background = new SolidColorBrush(Color.FromArgb(255, 255, 171, 0));

                                        break;
                                    }
                                case "Entertainment":
                                    {
                                        pin.Background = new SolidColorBrush(Color.FromArgb(255, 0, 26, 255));
                                        break;
                                    }
                            }

                            //Get and set pin location
                            pin.Location = new Location(DR.GetDouble(3), DR.GetDouble(4));

                            //Add pin tooltip (Event name)
                            ToolTipService.SetToolTip(pin, DR.GetValue(2));

                            //Add click event to pin
                            pin.MouseLeftButtonUp += Click_Pin;

                            //Add pin to pin layer
                            pinLayer.Children.Add(pin);

                            //Add all current event information to array
                            aList.Add(new Events(DR.GetValue(2).ToString(), DR.GetValue(8).ToString(), DR.GetDouble(3), DR.GetDouble(4), DR.GetTimeSpan(5), DR.GetTimeSpan(6), DR.GetDateTime(7), DR.GetInt16(9), DR.GetInt16(10), DR.GetInt16(0), DR.GetValue(11).ToString(), DR.GetValue(12).ToString()));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            // Add pinlayer on top of maplayer
            myMap.Children.Add(pinLayer);
        }
示例#45
0
        async Task TrackFlight(AirTelemetry AT, Location origin, Location destination, double miles)
        {
            string json="";
            var eventHubConnectionString = GetEventHubConnectionString();
            var eventHubClient = EventHubClient.CreateFromConnectionString(eventHubConnectionString, eventHubName);
            int runningMileCount = 0;
            int updateWeatherInverval = 200;
            int updateWeatherRadius = 300; 

            /* how many miles we go per tick */
            int mileageIncrement = 30;

            Pushpin pin = new Pushpin();
            Label infoLabel = new Label(); 
            MapLayer InfoLayer = new MapLayer();

            AT.RowKey += DateTime.Now.ToShortDateString();
            /* get rid of illegal characters in row key */
            AT.RowKey = Regex.Replace(AT.RowKey, @"[\ /?#]", "");

            MapPolyline polyline = new MapPolyline();
            polyline.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue);
            polyline.StrokeThickness = 5;
            polyline.Opacity = 0.7;

            /* pre-plot the course so that we can draw the flight path on the map. we recalculate the bearing every
             * 100 miles (could/should be configurable) to get a true Great Circle route. */
            Location prev = origin;
            Location nxtl;
            double hdg = AT.heading; 
            polyline.Locations=new LocationCollection();
            polyline.Locations.Add(origin); 
            int j;
            for (j = 2; ;j++ )
            {
                nxtl = Haversine.PositionDistanceFromOrigin(prev, mileageIncrement / 0.00062137, hdg); 
                polyline.Locations.Add(nxtl);
                hdg = Haversine.Bearing(nxtl, destination);
                prev = nxtl;
                if (Haversine.InRange(nxtl, destination.Latitude, destination.Longitude, 100))
                {
                    polyline.Locations.Add(destination);
                    break;
                }

            }
            string rkey = AT.RowKey;
            AT.lat = origin.Latitude;
            AT.lng = origin.Longitude;
            UpdateMap(AT, pin, polyline, InfoLayer);
            UpdateWeatherFromTable(origin, 300, new TimeSpan(3, 0, 0));

            int i; 

            for (i = 0; i <= polyline.Locations.Count; i++)
            {
                await Task.Delay(2000);
                try
                {
                    AT.RowKey = rkey +'-'+ i.ToString();          /* row key must be unique or will overwrite existing */ 
                    FlightMap.Children.Clear();
                    FlightMap.Children.Add(polyline);

                    InfoLayer.Children.Clear();
                    /* we have two time stamps. the first is inherited from TableEntity and normally should not be used by applications. We
                     * initialize it here because Stream Analytics will barf on an illegal data (dates must be greater than 
                     * 12:00 midnight, January 1, 1601 A.D. (C.E.), UTC.). We do not use the inherited time stamp after this; this is what
                     * AT.dto is for */ 
                    AT.Timestamp = DateTime.Now;
                    AT.dto = DateTimeOffset.Now; 
                    AT.inflight = "true";
                    /* send distance in meters */
                    Location p = Haversine.PositionDistanceFromOrigin(new Location(AT.lat, AT.lng), mileageIncrement / 0.00062137, AT.heading); 
                    AT.lat = p.Latitude;
                    AT.lng = p.Longitude;

                    double b2 = Haversine.Bearing(p, destination);
                    AT.heading = b2; 

                    /* altitude in meters */
                    if (i < 5)
                        AT.altitude = 10000 / (6 - (i + 1)); /* ascending */
                    else if ((polyline.Locations.Count - i) < 5)
                        AT.altitude = 10000 / (polyline.Locations.Count+1 - i); /* descending */
                    else
                        AT.altitude = 10000;

                    /* initialize the data structure */ 
                    AT.ice = 0.0;
                    AT.windspeed = 0.0;
                    AT.windshear = 0.0;
                    AT.lightning = 0.0; 

                    /* encode weather conditions */
                    if(ltice)
                    {
                        AT.ice = 5.0;
                        WeatherEvent we = new WeatherEvent(WeatherEventTypes.LIGHT_ICE, DateTime.Now, p);
                        weatherevents.Add(we); 
                        ltice = false;
                    }
                    else if(mdice)
                    {
                        AT.ice = 10.0;
                        WeatherEvent we = new WeatherEvent(WeatherEventTypes.MODERATE_ICE, DateTime.Now, p);
                        weatherevents.Add(we); 
                        mdice = false; 
                    }
                    else if (hvice)
                    {
                        AT.ice = 20.0;
                        WeatherEvent we = new WeatherEvent(WeatherEventTypes.HEAVY_ICE, DateTime.Now, p);
                        weatherevents.Add(we); 
                        hvice = false; 
                    }
                    if(mdtub)
                    {
                        AT.windspeed = 20.0;
                        WeatherEvent we = new WeatherEvent(WeatherEventTypes.MODERATE_TURB, DateTime.Now, p);
                        weatherevents.Add(we); 
                        mdtub = false;
                    }
                    else if(hvtub)
                    {
                        AT.windspeed = 40.0;
                        WeatherEvent we = new WeatherEvent(WeatherEventTypes.HEAVY_TURB, DateTime.Now, p);
                        weatherevents.Add(we); 
                        hvtub = false; 
                    }
                    if(mdshr)
                    {
                        AT.windshear = 20.0;
                        WeatherEvent we = new WeatherEvent(WeatherEventTypes.MODERATE_SHEAR, DateTime.Now, p);
                        weatherevents.Add(we); 
                        mdshr = false;
                    }
                    else if(hvshr)
                    {
                        AT.windshear = 40.0;
                        WeatherEvent we = new WeatherEvent(WeatherEventTypes.HEAVY_SHEAR, DateTime.Now, p);
                        weatherevents.Add(we); 
                        hvshr = false; 
                    }
                    if(tstrm)
                    {
                        AT.lightning = 50.0;
                        WeatherEvent we = new WeatherEvent(WeatherEventTypes.TSTORM, DateTime.Now, p);
                        weatherevents.Add(we); 
                        tstrm = false; 
                    }

                    json = Newtonsoft.Json.JsonConvert.SerializeObject(AT);
                    Console.WriteLine("{0} > Sending message: {1}", DateTime.Now.ToString(), json);

                    FlightMap.Center.Latitude = p.Latitude;
                    FlightMap.Center.Longitude = p.Longitude;
                    FlightMap.Center.Altitude = AT.altitude; 
                    Location center = FlightMap.Center;
                    double zoom = FlightMap.ZoomLevel; 
                    FlightMap.SetView(center, zoom);

                    pin.Location = center;
                    FlightMap.Children.Add(pin);

                    infoLabel.Content = AT.airline + " " + AT.flight;
                    InfoLayer.AddChild(infoLabel, center);
                    WeatherImageLayer(InfoLayer);
                    FlightMap.Children.Add(InfoLayer);

                    UpdateFlightInfoBox(AT, false); 

                    if(Haversine.InRange(new Location(AT.lat, AT.lng), destination.Latitude,destination.Longitude,50))
                        break; 

                    await eventHubClient.SendAsync(new EventData(Encoding.UTF8.GetBytes(json)));
                    runningMileCount += mileageIncrement;
                    if(runningMileCount>=updateWeatherInverval)
                    {
                        runningMileCount = 0;
                        weatherevents.Clear(); 
                        UpdateWeatherFromTable(new Location(AT.lat, AT.lng), updateWeatherRadius, new TimeSpan(3, 0, 0));
                    }
                }
                catch (Exception exception)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("{0} > Exception: {1}", DateTime.Now.ToString(), exception.Message);
                    Console.ResetColor();
                }


            }
            AT.arrival = DateTime.Now;
            AT.inflight = "false";

            /* fudge the destination position */

            AT.lat=FlightMap.Center.Latitude = destination.Latitude;
            AT.lng=FlightMap.Center.Longitude = destination.Longitude;
            FlightMap.Center.Altitude = AT.altitude;

            UpdateMap(AT, pin, polyline, InfoLayer); 
 
            json = Newtonsoft.Json.JsonConvert.SerializeObject(AT);
            await eventHubClient.SendAsync(new EventData(Encoding.UTF8.GetBytes(json)));
            UpdateFlightInfoBox(AT, true);
            
        }
        public void load_pushpins()
        {
            SqlCeConnection conn = null;

            string filesPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NatureNetDataBase_Main.sdf");
            string connectionString = string.Format("Data Source=" + filesPath);
            conn = new SqlCeConnection(connectionString);
            SqlCeCommand cmd = conn.CreateCommand();
            cmd.CommandText = "SELECT COUNT(*) AS NumberOfOrders FROM PushPin_location";
            conn.Open();
            object value4 = cmd.ExecuteScalar();

            for (int i = 1; i <= Convert.ToInt32( value4); i++)
            {
                double x_position;
                double y_position;
                cmd.CommandText = "SELECT x_position FROM PushPin_location WHERE (pin_tag = N'"+i+"')";

                x_position = Convert.ToDouble( cmd.ExecuteScalar());
                cmd.CommandText = "SELECT y_position FROM PushPin_location WHERE (pin_tag = N'" + i + "')";
                y_position = Convert.ToDouble(cmd.ExecuteScalar());
                MapLayer layer2 = new MapLayer();

                Location pinLocation = new Location(x_position,y_position);

                PushPinControl asdfgh = new PushPinControl(pinLocation);

                layer2.AddChild(asdfgh, pinLocation, PositionOrigin.Center);
                // The pushpin to add to the map.
                // Pushpin pin = new Pushpin();
                // pin.Location = pinLocation;
                //mymap.Children.
                // Adds the pushpin to the map.
                // mymap.Children.Add(pin);
                // asdfgh.pinno.Content = count;
                mymap.Children.Add(layer2);

            }
            conn.Close();
        }
示例#47
0
        // Load data for the ViewModel Items
        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            pb.IsIndeterminate = true;
            pb.Visibility = Visibility.Visible;

            if (!App.ViewModel.IsDataLoaded)
            {
                App.ViewModel.LoadData(0);
                App.ViewModel.PropertyChanged += loadingBar;
            }
            DateRight.Tap += IncreaseDate;
            DateLeft.Tap += DecreaseDate;
            DateSelect.Tap += SetDate;
            DateSelectIcon.Tap += SetDate;

            MapLocation.Tap += CenterMap;
            MapDirections.Tap += FindDirections;
            try
            {
                HSGLocation.SetView(new GeoCoordinate(Latitude, Longitude), 17);

                Image image = new Image();
                image.Source = new BitmapImage(new Uri("hsglogo.png", UriKind.RelativeOrAbsolute));
                image.Stretch = Stretch.None;
                Location location = new GeoCoordinate(Latitude, Longitude);
                PositionOrigin position = PositionOrigin.BottomCenter;
                MapLayer mapLayer = new MapLayer();

                mapLayer.AddChild(image, location, position);
                MapLayer.SetPositionOffset(image, new Point(0, 0));

                HSGLocation.Children.Add(mapLayer);
            }
            catch (Exception)
            {
                MessageBox.Show("Unable to configure map. Please check your network connection.");
            }
        }
        private void mymap_TouchDown(object sender, TouchEventArgs e)
        {
            if (check == 1)
            {
                MapLayer layer2 = new MapLayer();
                e.Handled = true;

                // Determin the location to place the pushpin at on the map.

                //Get the mouse click coordinates
                TouchPoint touchp = e.GetTouchPoint(this);
                //Convert the mouse coordinates to a locatoin on the map
                Location pinLocation = mymap.ViewportPointToLocation(touchp.Position);

                PushPinControl asdfgh = new PushPinControl(pinLocation);

                layer2.AddChild(asdfgh, pinLocation, PositionOrigin.Center);
                // The pushpin to add to the map.
                // Pushpin pin = new Pushpin();
                // pin.Location = pinLocation;
                //mymap.Children.
                // Adds the pushpin to the map.
                // mymap.Children.Add(pin);
               // asdfgh.pinno.Content = count;
                mymap.Children.Add(layer2);
                count++;
                check = 0;
                Drop_controler.Tag = "isdisabled";

            }
        }
示例#49
0
        private async void AddressMapping()
        {
            googlemap.Children.Remove(pushPinLayer);
            pushPinLayer = new MapLayer();

            try
            {
                GeoCoordinate geo = new GeoCoordinate(MainPage.bookingData.lat, MainPage.bookingData.lng);

                Microsoft.Phone.Controls.Maps.Pushpin new_pushpin = new Microsoft.Phone.Controls.Maps.Pushpin();
                new_pushpin.Location = geo;
                googlemap.Center = geo;

                string url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + geo.Latitude + "," + geo.Longitude + "&sensor=true";
                var client = new WebClient();

                string response = await client.DownloadStringTaskAsync(new Uri(url));
                JObject root = JObject.Parse(response);

                JArray items = (JArray)root["results"];
                JObject item;
                JToken jtoken;
                item = (JObject)items[0];
                JArray add_comp = (JArray)item["address_components"];
                string address = null;
                string[] add_types = { "street_number", "route", "neighborhood", "locality", "city", "country" };
                foreach (var comp in add_comp)
                {
                    if (add_types.Any(comp["types"].ToString().Contains))
                    {
                        address += comp["long_name"].ToString() + ", ";
                        if (comp["types"].ToString().Contains("city") | comp["types"].ToString().Contains("country"))
                        {
                            address += "\n";
                        }
                    }
                }

                (ApplicationBar.Buttons[0] as ApplicationBarIconButton).IsEnabled = true;
                (ApplicationBar.Buttons[2] as ApplicationBarIconButton).IsEnabled = true;

                new_pushpin.Content = "Destination Location:\n" + address;

                Address.Text = address;
                new_pushpin.Visibility = Visibility.Visible;

                googlemap.Children.Add(pushPinLayer);
                pushPinLayer.AddChild(new_pushpin, geo, PositionOrigin.BottomLeft);
                MainPage.bookingData.set_destination_attributes(address, geo);
                LatitudeTextBlock.Text = "Latitude:  " + geo.Latitude.ToString("0.00"); //geoposition.Coordinate.Latitude.ToString("0.00"); //
                LongitudeTextBlock.Text = "Longitude: " + geo.Longitude.ToString("0.00");//geoposition.Coordinate.Longitude.ToString("0.00"); //
            }
            catch (Exception ed)
            {
                MessageBox.Show(ed.ToString());
            }
        }
        void ShowMap()
        {
            myMap.Children.Clear();

            List<Flight> selected = GetSelectedFlights();
            if (selected.Count == 0)
            {
                // show everything.
                selected.Add(new Flight() { StartTime = DateTime.MinValue, Duration = TimeSpan.MaxValue });
            }
            var glitchIcon = XamlExtensions.LoadImageResource("Assets.GpsGlitchIcon.png");
            var imageLayer = new MapLayer();
            myMap.Children.Add(imageLayer);
            MapPolyline last = currentFlight;
            foreach (IDataLog log in this.logs)
            {
                if (log != null)
                {
                    bool gpsIsBad = false;
                    foreach (var flight in selected)
                    {
                        if (flight.Log == null || flight.Log == log)
                        {
                            MapPolyline line = new MapPolyline();
                            line.StrokeThickness = 4;
                            line.Stroke = new SolidColorBrush(HlsColor.GetRandomColor());
                            LocationCollection points = new LocationCollection();

                            Debug.WriteLine("time,\t\tlat,\t\tlong,\t\t\tnsat,\talt,\thdop,\tfix");
                            foreach (var row in log.GetRows("GPS", flight.StartTime, flight.Duration))
                            {
                                LogEntryGPS gps = new LogEntryGPS(row);
                                //Debug.WriteLine("{0},\t{1},\t{2},\t{3},\t\t{4:F2},\t{5},\t{6}", gps.TimeMS,  gps.Lat, gps.Lng, gps.NSats, gps.Alt, gps.HDop, gps.Fix);
                                if (!(gps.Lat == 0 && gps.Lon == 0))
                                {
                                    var pos = new Location() { Altitude = gps.Alt, Latitude = gps.Lat, Longitude = gps.Lon };
                                    points.Add(pos);
                                    ulong time = (ulong)gps.GPSTime;
                                    if (time != 0)
                                    {
                                        if ((gps.nSat < 5 || gps.EPH > 20))
                                        {
                                            if (!gpsIsBad)
                                            {
                                                gpsIsBad = true;
                                                Debug.WriteLine("{0},\t{1},\t{2},\t{3},\t\t{4:F2},\t{5},\t{6}", gps.GPSTime, gps.Lat, gps.Lon, gps.nSat, gps.Alt, gps.EPH, gps.Fix);
                                                Image img = new Image();
                                                img.Width = 30;
                                                img.Height = 30;
                                                img.Source = glitchIcon;
                                                img.Stretch = Stretch.None;
                                                img.ToolTip = "GPS Glitch!";
                                                imageLayer.AddChild(img, pos, PositionOrigin.Center);
                                            }
                                        }
                                        else
                                        {
                                            gpsIsBad = false;
                                        }
                                    }
                                }
                            }
                            if (points.Count > 0)
                            {
                                line.Locations = points;
                                myMap.Children.Add(line);
                                last = line;
                            }
                        }
                    }
                }
            }

            ModelViewer.Visibility = Visibility.Collapsed;
            Messages.Visibility = Visibility.Collapsed;
            ChartStack.Visibility = Visibility.Collapsed;
            TextButton.IsChecked = false;
            myMap.Visibility = Visibility.Visible;
            myMap.UpdateLayout();

            if (last != null)
            {
                try
                {
                    myMap.SetView(last.Locations, new Thickness(20.0), 0);
                }
                catch (Exception ex)
                {
                    ShowStatus(ex.Message);
                }
            }

        }
示例#51
0
 private void UpdateMap(AirTelemetry at, Pushpin pin, MapPolyline polyline, MapLayer layer)
 {
     Label lbl = new Label();
     lbl.Content = at.airline + " " + flight;
     FlightMap.Center.Latitude = at.lat;
     FlightMap.Center.Longitude = at.lng; 
     FlightMap.Center.Altitude = at.altitude;
     Location centerd = FlightMap.Center;
     double zoomd = FlightMap.ZoomLevel;
     FlightMap.SetView(centerd, zoomd);
     pin.Location = centerd;
     FlightMap.Children.Clear();
     FlightMap.Children.Add(polyline);
     FlightMap.Children.Add(pin);
     layer.Children.Clear(); 
     layer.AddChild(lbl, centerd);
     WeatherImageLayer(layer);
     FlightMap.Children.Add(layer);
 }
        //void cityLookup_cityFoundEvent(string city)
        //{
        //this.currentCity = city;
        //InitializeMap();
        //}
        public void InitializeMap()
        {
            //currentCity = "Valletta";

            // get all localized entries
            IEnumerator localizedEntries = LocationData.Instance.GetEnumerator();
            //List<GeoCoordinate> locations = new List<GeoCoordinate>();

            imageLayer = new MapLayer();
            map1.Children.Add(imageLayer);

            detailsCanvas = new Canvas();
            map1.Children.Add(detailsCanvas);

            // loop through localized entries
            while ( localizedEntries.MoveNext() )
            {
                KeyValuePair<string, SimpleCoordinates> entry = (KeyValuePair<string, SimpleCoordinates>)localizedEntries.Current;

                if ( LocationIsClose(entry.Value.Latitude, entry.Value.Longitude) )
                {
                    //Pushpin pin = new Pushpin();
                    GeoCoordinate location = new System.Device.Location.GeoCoordinate(entry.Value.Latitude, entry.Value.Longitude);
                   // locations.Add(location);

                    Image pinImage = new Image();
                    pinImage.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("marker-red.png", UriKind.Relative));
                    pinImage.Opacity = 0.9;
                    pinImage.Stretch = System.Windows.Media.Stretch.None;
                    pinImage.Tag = entry.Key;
                    pinImage.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(pin_Tap);

                    imageLayer.AddChild(pinImage, location);
                }
            }

            // set map view
            map1.SetView(new GeoCoordinate(currentLat, currentLon), 15.0);
        }
示例#53
0
 public void AddPushPin(List<ListaReal> list)
 {
     map.Children.Clear();
     map.Children.Add(RomaniaMap());
     foreach (var lol in list)
     {
        
             Canvas c = new Canvas() { Width = 7, Height = 7 };
             #region NivelProblema
             if (lol.InivelProblema == 1)
             { c.Background = new SolidColorBrush(Colors.Red); c.Opacity = 0.99; }
             else if (lol.InivelProblema == 2)
             { c.Background = new SolidColorBrush(Colors.White); c.Opacity = 0.98; }
             else if (lol.InivelProblema == 3)
             { c.Background = new SolidColorBrush(Colors.Orange); c.Opacity = 0.97; }
             #endregion
       
         c.MouseEnter += new MouseEventHandler(c_MouseEnter);
         c.MouseLeave += new MouseEventHandler(c_MouseLeave);
         c.MouseLeftButtonDown += new MouseButtonEventHandler(c_MouseLeftButtonDown);
         MapLayer l = new MapLayer();
            #region NumeCampanie
         TextBlock tx = new TextBlock() { Foreground = new SolidColorBrush(Colors.White), FontSize = 15, FontFamily = new FontFamily("Tahoma") };
         tx.Text = lol.nume;
         tx.Visibility = Visibility.Collapsed;
         c.Children.Add(tx);
         Canvas.SetLeft(tx,50);
         Canvas.SetTop(tx, 5);
          #endregion    
         tx = new TextBlock() { Foreground = new SolidColorBrush(Colors.White), FontSize = 13, FontFamily = new FontFamily("Tahoma") };
         tx.Text ="Location: "+ lol.locatie;
         tx.Visibility = Visibility.Collapsed;
         c.Children.Add(tx);
         Canvas.SetLeft(tx, 10);
         Canvas.SetTop(tx, 30);
         l.AddChild(c, lol.x);
         map.Children.Add(l);
     }
 }
示例#54
0
        private MapLayer WeatherImageLayer(MapLayer imageLayer)
        {
            int imageDimension = 60; 
            foreach(WeatherEvent we in weatherevents)
            {
                Image image = new Image();
                image.Height = imageDimension;
                image.Width = imageDimension; 
                //Define the URI location of the image
                BitmapImage myBitmapImage = new BitmapImage();

                myBitmapImage.BeginInit();
                switch(we.eventtype)
                {
                    case WeatherEventTypes.LIGHT_ICE:
                        myBitmapImage.UriSource = new Uri(Directory.GetCurrentDirectory() + @"\ice.png", UriKind.Absolute); 
                        break;
                    case WeatherEventTypes.MODERATE_ICE:
                        myBitmapImage.UriSource = new Uri(Directory.GetCurrentDirectory() + @"\ice.png", UriKind.Absolute); 
                        break;
                    case WeatherEventTypes.HEAVY_ICE:
                        myBitmapImage.UriSource = new Uri(Directory.GetCurrentDirectory() + @"\ice.png", UriKind.Absolute); 
                        break;
                    case WeatherEventTypes.TSTORM:
                        myBitmapImage.UriSource = new Uri(Directory.GetCurrentDirectory() + @"\lightning.png", UriKind.Absolute); 
                        break;
                    case WeatherEventTypes.MODERATE_TURB:
                        myBitmapImage.UriSource = new Uri(Directory.GetCurrentDirectory() + @"\turb.png", UriKind.Absolute); 
                        break;
                    case WeatherEventTypes.HEAVY_TURB:
                        myBitmapImage.UriSource = new Uri(Directory.GetCurrentDirectory() + @"\turb.png", UriKind.Absolute); 
                        break;
                    case WeatherEventTypes.MODERATE_SHEAR:
                        myBitmapImage.UriSource = new Uri(Directory.GetCurrentDirectory() + @"\shear.png", UriKind.Absolute); 
                        break;
                    case WeatherEventTypes.HEAVY_SHEAR:
                        myBitmapImage.UriSource = new Uri(Directory.GetCurrentDirectory() + @"\shear.png", UriKind.Absolute);  
                        break;

                }
                myBitmapImage.DecodePixelHeight = imageDimension;
                myBitmapImage.DecodePixelWidth = imageDimension; 
                myBitmapImage.EndInit();
                image.Source = myBitmapImage;
                image.Opacity = 1.0;
                image.Stretch = System.Windows.Media.Stretch.Fill;

                //Center the image around the location specified
                PositionOrigin position = PositionOrigin.Center;
                //Add the image to the defined map layer
                imageLayer.AddChild(image, we.location, position);
            }
            return imageLayer; 
        }
示例#55
0
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            double latitude = -25.292; 
            double longitude = -65.353;

            //Agregar un Hexágono
            MapPolygon polygon = new MapPolygon();
            polygon.Fill = new LinearGradientBrush(new GradientStopCollection() 
            { 
                new GradientStop { Color = Colors.Black, Offset = 0 },
                new GradientStop { Color = Colors.White, Offset = 1 }
            }, 0);
            //polygon.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red);
            polygon.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Yellow);
            polygon.StrokeThickness = 5;
            polygon.Opacity = 0.7;
            polygon.Locations = RenderHexagon(latitude, longitude);

            mapControl.Children.Add(polygon);

            MapLayer imageLayer = new MapLayer();
            imageLayer.Name = "ImageLayer";

            /*
            Pushpin pin = new Pushpin();
            pin.ContentTemplate = this.Resources["PinTemplate"] as DataTemplate;
            pin.Location = new Location(latitude, longitude);
            mapControl.Children.Add(pin);
             * */

            
            Image image = new Image();
            image.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("G.png", UriKind.Relative));
            image.Opacity = 1;
            image.Stretch = System.Windows.Media.Stretch.None;
            image.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            image.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            image.RenderTransformOrigin = new Point(0.5, 0.5);
            imageLayer.AddChild(image, new Location(latitude, longitude), PositionOrigin.Center);
            //Add the image layer to the map
            mapControl.Children.Add(imageLayer);
            

            /*
            //Agrego un Tile Layer
            tileLayer = new MapTileLayer();

            // The source of the overlay.
            LocationRectTileSource tileSource = new LocationRectTileSource();
            tileSource.UriFormat = "https://guardianes.blob.core.windows.net/landsat/20130603_NEW/";
            // The zoom range that the tile overlay is visibile within
            tileSource.ZoomRange = new Range<double>(6, 13);
            // The bounding rectangle area that the tile overaly is valid in.
            tileSource.BoundingRectangle = mapControl.BoundingRectangle;

            // Adds the tile overlay to the map layer
            tileLayer.TileSources.Add(tileSource);

            // Adds the map layer to the map
            if (!mapControl.Children.Contains(tileLayer))
            {
                mapControl.Children.Add(tileLayer);
            }



            var topLeft = FromLonLat(mapControl.BoundingRectangle.West, mapControl.BoundingRectangle.North);
            var bottomRight = FromLonLat(mapControl.BoundingRectangle.East, mapControl.BoundingRectangle.South);

            var extent = new BruTile.Extent(topLeft.X, bottomRight.Y, bottomRight.X, topLeft.Y);

            var schema = new SphericalMercatorWorldSchema();
            schema.Extent = extent;

            var tiles = schema.GetTilesInView(extent, 12);
            foreach (var tile in tiles)
            {

            }
             * */

        }
        private void addImageToMap(object sender, RoutedEventArgs e)
        {
            MapLayer imageLayer = new MapLayer();

            Image image = new Image();
            image.Height = 150;
            //Define the URI location of the image
            BitmapImage myBitmapImage = new BitmapImage();
            myBitmapImage.BeginInit();
            myBitmapImage.UriSource = new Uri("http://upload.wikimedia.org/wikipedia/commons/d/d4/Golden_Gate_Bridge10.JPG");
            // To save significant application memory, set the DecodePixelWidth or
            // DecodePixelHeight of the BitmapImage value of the image source to the desired
            // height or width of the rendered image. If you don't do this, the application will
            // cache the image as though it were rendered as its normal size rather then just
            // the size that is displayed.
            // Note: In order to preserve aspect ratio, set DecodePixelWidth
            // or DecodePixelHeight but not both.
            //Define the image display properties
            myBitmapImage.DecodePixelHeight = 150;
            myBitmapImage.EndInit();
            image.Source = myBitmapImage;
            image.Opacity = 0.6;
            image.Stretch = System.Windows.Media.Stretch.None;

            //The map location to place the image at
            Location location = new Location() { Latitude = 37.8197222222222, Longitude = -122.478611111111 };
            //Center the image around the location specified
            PositionOrigin position = PositionOrigin.Center;

            //Add the image to the defined map layer
            imageLayer.AddChild(image, location, position);
            //Add the image layer to the map
            MapTileOverlay.Children.Add(imageLayer);
        }