public LocationsPage()
        {
            this.InitializeComponent();

            this.LocationMap.PointerPressedOverride += LocationMap_PointerPressedOverride;
            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            if (localSettings.Values["CurrentLocName"] != null &&
                localSettings.Values["CurrentLocLat"] != null &&
                localSettings.Values["CurrentLocLon"] != null)
            {
                Location myLocation = new Location();
                myLocation.Latitude = Convert.ToDouble(localSettings.Values["CurrentLocLat"]);
                myLocation.Longitude = Convert.ToDouble(localSettings.Values["CurrentLocLon"]);
                Pushpin myPoint = new Pushpin();
                myPoint.SetValue(MapLayer.PositionProperty, myLocation);
                myPoint.Selected = true;
                this.LocationMap.Children.Add(myPoint);
                this.LocationMap.Center = myLocation;
                this.LocationMap.ZoomLevel = 10;

                this.LatBox.Text = myLocation.Latitude.ToString();
                this.LonBox.Text = myLocation.Longitude.ToString();
                this.NameBox.Text = localSettings.Values["CurrentLocName"].ToString();
            }
        }
Exemplo n.º 2
0
        public MainPage()
        {
            this.InitializeComponent();

            currentLocationPushpin = new Pushpin();
            currentLocationPushpin.Background = new SolidColorBrush(Colors.Black);

            myMap.Children.Add(currentLocationPushpin);

            locator = new Geolocator();
            locator.MovementThreshold = 10;
            locator.PositionChanged += locator_PositionChanged;

            // Set up geofence loader
            this.loader = new GeofenceLoader(new Uri("http://localhost:1337"));
            loader.PropertyChanged += loader_PropertyChanged;

            // Set up geofence NH registration manager
            // Fake channel because otherwise it won't work in simulator
            var channel = "https://bn1.notify.windows.com/?token=AgYAAADCM0ruyKKQnGeNHSWDfdqWh9aphe244WGh0%";
            this.registrationManager = new GeofenceRegistrationManager(
                MobileSecrets.NotificationHubName,
                MobileSecrets.NotificationHubConnectionString,
                channel);

        }
Exemplo n.º 3
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            // Allow saved page state to override the initial item to display

            App app = (App)Application.Current;
            incident= app.ActiveIncident;

            ActiveDeployment = app.ActiveMap;

            DataContext = incident;
            CategoryTextBlock.Text = " ";
            foreach (Category cat in incident.categories)
            {

                CategoryTextBlock.Text += cat.category.title + " | ";
            }

            Pushpin pushpin = new Pushpin();
            pushpin.Tag = incident.incident.incidenttitle;
               // pushpin.Text = incident.incident.incidentdescription;

            Location location = new Location()
            {
                Latitude = incident.incident.Latitude,
                Longitude = incident.incident.Longitude
            };

            ToolTipService.SetToolTip(pushpin, incident.incident.incidenttitle);

            MapLayer.SetPosition(pushpin, location);
            ReportMap.Children.Add(pushpin);

            ReportMap.SetView(location, 14);
        }
Exemplo n.º 4
0
        public MainWindow()
        {
            InitializeComponent();

            //GMapProvider.WebProxy = WebRequest.DefaultWebProxy;
            // or
            //GMapProvider.WebProxy = new WebProxy("127.0.0.1", 1080);
            //GMapProvider.IsSocksProxy = true;

            GMaps.Instance.EnableTileHost(8844);

            Closing += new CancelEventHandler(MainWindow_Closing);

            // The pushpin to add to the map.
            Pushpin pin = new Pushpin();
            {
                pin.Location = map.Center;

                pin.ToolTip = new Label()
                {
                    Content = "GMap.NET fusion power! ;}"
                };
            }
            map.Children.Add(pin);
        }
Exemplo n.º 5
0
		//Tile events
		private void UIElement_OnTapped(object sender, TappedRoutedEventArgs e)
		{
			if (_isWorking == false) //prevent multiple operations on the same object == null reference exceptions
			{
                _isWorking = true;

			    try //Hacky, very very hacky :(
			    {
                    CleanupMap();

			        var x = (TruckObject) TruckGallery.SelectedItem;

			        var pushpin2 = new Pushpin();
			        pushpin2.Text = "!";
			        MapLayer.SetPosition(pushpin2, new Location(Convert.ToDouble(x.LocLat), Convert.ToDouble(x.LocLong)));
			        MyMap.Children.Add(pushpin2);
			    }
			    catch
			    {
			        
			    }

				_isWorking = false;
			}
		}
 void AddPin(string text,double latitude, double longitude)
 {
     Pushpin pushpin = new Pushpin();
     pushpin.Text = text;
     MapLayer.SetPosition(pushpin, new Location(latitude, longitude));
     myMap.Children.Add(pushpin);
 }
Exemplo n.º 7
0
        private async void ProcessTweet(Tweet tweet) {

            if (!string.IsNullOrEmpty(tweet.Latitude) &&
                !string.IsNullOrEmpty(tweet.Longitude)) {

                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {

                    Pushpin pushpin = new Pushpin();
                    pushpin.Tapped +=
                        async (s, e) => {

                            MessageDialog dialog = new MessageDialog(
                                tweet.TweetText, 
                                string.Concat("Tweet by ", tweet.User));

                            await dialog.ShowAsync();
                        };

                    MapLayer.SetPosition(pushpin, 
                        new Location(
                            double.Parse(tweet.Latitude), 
                            double.Parse(tweet.Longitude)));

                    BingMap.Children.Add(pushpin);
                });
            }
        }
Exemplo n.º 8
0
        public MainPage()
        {
            
            this.InitializeComponent();
            _geolocator = new Geolocator();
            _geolocator.DesiredAccuracy = PositionAccuracy.High;
            _geolocator.PositionChanged += new TypedEventHandler<Geolocator, PositionChangedEventArgs>(OnPositionChanged);
            //map.SetView(new Location(18.264015, -66.430797), 10);//To set the startup location of the map via code.
            //map.MapType = MapType.Road; //To change the map style via code.

            //Geolocation pushpin
            pin = new Pushpin
            {
                Background = new SolidColorBrush(Colors.Red)
               
            };
            map.Children.Add(pin);

            Rect display = Window.Current.Bounds;

            map.Width = display.Width;
            map.Height = display.Height;

            double cbPosX = (map.Width / 2) - (cbMunicipalities.Width / 2);
            double cbPosY = (map.Height / 4) * 3.5 - (cbMunicipalities.Height / 2);

            cbMunicipalities.Margin = new Thickness(cbPosX, cbPosY, 0, 0);
            
           
            
        }
Exemplo n.º 9
0
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            var error = false;
            pageTitle.Text = "Hi, " + App.User.Fullname;
            try
            {
                var existingDisasters = await Service.GetTable<Disaster>()
                    .Where(t => t.Active == DisasterStatusType.Active).ToListAsync();
                lstDisasters.ItemsSource = existingDisasters;
                foreach(var item in existingDisasters)
                {
                    var pin = new Pushpin();
                    pin.Text = item.Description;
                    map.Children.Add(pin);
                    MapLayer.SetPosition(pin, new Location(item.Latitude, item.Longitude));
                }
            }
            catch (Exception ex)
            {
                error = true;
            }

            if(error)
            {
                await new MessageDialog("Something went wrong!").ShowAsync();
                return;
            }
            geolocator = new Geolocator();
            geolocator.DesiredAccuracy = PositionAccuracy.High;
            geolocator.DesiredAccuracyInMeters = 100;
            var location = await geolocator.GetGeopositionAsync();
            map.Center = new Location(location.Coordinate.Latitude, location.Coordinate.Longitude);
        }
Exemplo n.º 10
0
        async void load()
        {
            WebProxy proxy = new WebProxy();
          
            try
            {

                App myapp = (App)Application.Current;
                
                if (myapp.Deployments == null)
                {
                    ProgressBar.Visibility = Windows.UI.Xaml.Visibility.Visible;
                    LocalStorage local = new LocalStorage();
                    var maps = await proxy.GetDeployments();                  
                    myapp.Deployments = maps;

                    if (local.Deployments.Count > 0)
                    {
                        myapp.Deployments.AddRange(local.Deployments);
                    }
                   
                }
                ProgressBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                DeploymentListView.ItemsSource = myapp.Deployments;
              
             
                foreach (Deployment deploy in myapp.Deployments)
                {
                      

                    Pushpin pushpin = new Pushpin();
                    //pushpin.Text = deploy.name;

                    Location location = new Location();
                    double lat ,lon;
                    double.TryParse(deploy.latitude, out lat);
                    double.TryParse(deploy.longitude,out lon);
                    location.Longitude = lon;
                    location.Latitude = lat;
                    pushpin.Tapped+=pushpin_Tapped;
                    pushpin.Tag = deploy;

                    MapLayer.SetPosition(pushpin, location);

                    ToolTipService.SetToolTip(pushpin, deploy.name);

                    DeploymentMap.Children.Add(pushpin);
                }


            }
            catch (Exception ex)
            {
                MessageDialog msg = new MessageDialog(ex.Message+ ex.StackTrace);
                msg.ShowAsync();
            }

        }
Exemplo n.º 11
0
        public MapTile ()
        {
            this.InitializeComponent ();

            map.Credentials = Constants.BingMapsKey;
            pin = new Pushpin ();
            pin.Tapped += OnPinTapped;
            map.Children.Add (pin);
            map.ShowNavigationBar = false;
            map.ShowScaleBar = false;
        }
Exemplo n.º 12
0
        private void OnFlightRouteReady(object sender, FlightRouteReadyEventArgs args)
        {
            if (flightRouteUIElementsMap.ContainsKey(args.FlightPlanName))
            {
                // we already have a collection describing this particular route.
                // don't need to add a copy.
                return;
            }

            // polyline + markers
            List <UIElement> flightUIElem = new List <UIElement>(args.FlightPlan.waypoints + 1);

            MapPolyline polyline = new MapPolyline();
            Color       color    = RouteColors[ColorIndex++ % RouteColors.Length];

            polyline.Stroke          = new SolidColorBrush(color);
            polyline.StrokeThickness = 5;
            polyline.Opacity         = 0.7;

            LocationCollection collection = new LocationCollection();

            for (int i = 0; i < args.FlightPlan.waypoints; i++)
            {
                // fill polyline
                NavigationNode currentNode = args.FlightPlan.route.nodes[i];

                collection.Add(new Location(currentNode.lat, currentNode.lon));

                // add marker
                Pushpin pin = new Pushpin();
                pin.Location   = new Location(currentNode.lat, currentNode.lon);
                pin.ToolTip    = args.FlightPlan.notes;
                pin.Content    = currentNode.type;
                pin.Background = GetColorFromNavigationNodeType(currentNode.type);

                BingMap.Children.Add(pin);
                flightUIElem.Add(pin);
            }

            polyline.Locations = collection;

            BingMap.Children.Add(polyline);
            flightUIElem.Add(polyline);

            flightRouteUIElementsMap.Add(args.FlightPlanName, flightUIElem);

            FlightRouteDrawEventArgs e = new FlightRouteDrawEventArgs();

            e.FlightRouteData = args;
            e.RouteColor      = color;

            NewFlightRouteDrawDelegate?.Invoke(this, e);
        }
Exemplo n.º 13
0
        private void AddPushpin(Location locationToAdd)
        {
            Pushpin newPushpin = new Pushpin {
                Location   = locationToAdd,
                Background = Brushes.Red
            };
            POI newPOI = new POI(locationToAdd.Latitude, locationToAdd.Longitude);

            newPOI.Tag = newPushpin;
            MapData.Add(newPOI);
            MyMap.Children.Add(newPushpin);
        }
Exemplo n.º 14
0
        private void Map_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            e.Handled = true;

            Point   mousePosition = e.GetPosition(this);
            Pushpin pin           = new Pushpin();

            pin.Location = MyMap.ViewportPointToLocation(mousePosition);
            MyMap.Children.Add(pin);
            var lat = pin.Location.Latitude;
            var lon = pin.Location.Longitude;
        }
Exemplo n.º 15
0
        private void map_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            e.Handled = true;
            Point mousePosition = e.GetPosition(this);

            Location pinLocation = map.ViewportPointToLocation(mousePosition);

            Pushpin pin = new Pushpin();
            pin.Location = pinLocation;

            map.Children.Add(pin);
        }
Exemplo n.º 16
0
        private void InitMap()
        {
            map1.Center    = new System.Device.Location.GeoCoordinate(22.626197, 120.285605);
            map1.ZoomLevel = 16;

            Pushpin pp = new Pushpin();

            pp.Location   = new GeoCoordinate(22.626197, 120.285605);
            pp.Background = new SolidColorBrush(Colors.Green);
            pp.Content    = string.Format("{0}\r\n{1}", "高雄國際會議中心ICCK", "高雄市鹽埕區中正四路274號");
            map1.Children.Add(pp);
        }
Exemplo n.º 17
0
        private void MyMap_OnLoaded(object sender, RoutedEventArgs e)
        {
            var map           = (Bing.Maps.Map)sender;
            var mapShapeLayer = new MapShapeLayer();
            var polyLine      = new MapPolyline();

            var activities = map.Tag as List <Activity>;

            if (activities == null)
            {
                return;
            }

            var pinNumber = 0;

            foreach (var activity in activities
                     .GroupBy(x => x.Latitude + x.Longitude) //ignore dupe coordinates
                     .Select(g => g.First())
                     .OrderBy(x => x.Timestamp))
            {
                // ReSharper disable CompareOfFloatsByEqualityOperator
                if (activity.Latitude != 0 && activity.Longitude != 0)
                {
                    polyLine.Locations.Add(new Location(activity.Latitude, activity.Longitude));

                    pinNumber++;
                    var pin = new Pushpin();
                    pin.Text     = pinNumber.ToString();
                    pin.FontSize = 13; //this size works good for single or double digits

                    MapLayer.SetPosition(pin, new Location(activity.Latitude, activity.Longitude));
                    map.Children.Add(pin);
                }
                // ReSharper restore CompareOfFloatsByEqualityOperator
            }

            polyLine.Width = 3;
            mapShapeLayer.Shapes.Add(polyLine);
            map.ShapeLayers.Add(mapShapeLayer);

            //Calculate a bounding box for the route
            var t = activities.Where(x => x.Latitude != 0).Max(x => x.Latitude);
            var b = activities.Where(x => x.Latitude != 0).Min(x => x.Latitude);
            var l = activities.Where(x => x.Longitude != 0).Min(x => x.Longitude);
            var r = activities.Where(x => x.Longitude != 0).Max(x => x.Longitude);

            //Pad the box
            var latPad  = (t - b) * .3;
            var longPad = (r - l) * .3;

            map.SetView(new LocationRect(new Location(t + latPad, l - longPad), new Location(b - latPad, r + longPad)), MapAnimationDuration.None);
        }
Exemplo n.º 18
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            pinLayer.Children.Clear();
            lineLayer.Children.Clear();
            lineLabelLayer.Children.Clear();
            stopLabelLayer.Children.Clear();
            circleLayer.Children.Clear();

            MetroMap.Center = NearStopsUri.CenterLocation;
            DrawCircle(NearStopsUri.CenterLocation, NearStopsUri.Dist);

            List <Stop> StopsResults = Stops.GetNearStops();

            if (StopsResults.Count > 0)
            {
                foreach (Stop stop in StopsResults)
                {
                    Location pinLocation = new Location(stop.Lat, stop.Lon);

                    TextBlock label = new TextBlock()
                    {
                        Text       = stop.ToString(),
                        Background = new SolidColorBrush(Colors.AliceBlue),
                        FontSize   = 12,
                        Padding    = new Thickness(5),
                    };

                    Image busIcon = new Image()
                    {
                        Source = new BitmapImage(new Uri("./images/bus_symbol.png", UriKind.Relative))
                    };

                    Pushpin pin = new Pushpin
                    {
                        Location    = pinLocation,
                        DataContext = label,
                        Content     = busIcon,
                    };

                    pin.MouseEnter += new MouseEventHandler(StopMouseEnter);
                    pin.MouseLeave += new MouseEventHandler(StopMouseLeave);

                    pinLayer.Children.Add(pin);
                }


                foreach (MetroApp.Line line in Stops.LineCollection)
                {
                    DrawLine(line);
                }
            }
        }
Exemplo n.º 19
0
        public static void AddTextMessage(string txtXml, Color color)
        {
            Map.Dispatcher.Invoke(() =>
            {
                textMessage txt = null;

                try
                {
                    txt = Serialization.Deserialize <textMessage>(txtXml);
                }
                catch (Exception)
                {
                }

                if (txt != null)
                {
                    if (txt.position != null)
                    {
                        Pushpin pin  = new Pushpin();
                        pin.Location = new Location((double)txt.position.lat, (double)txt.position.lon);
                        pin.ToolTip  = txt.subject;
                        Map.Children.Add(pin);
                    }

                    if (txt.area != null && txt.area.Polygon != null)
                    {
                        MapPolyline polyline     = new MapPolyline();
                        polyline.Stroke          = new SolidColorBrush(color);
                        polyline.StrokeThickness = 2;
                        polyline.Opacity         = 0.7;

                        polyline.Locations = new LocationCollection();
                        var points         = txt.area.Polygon.posList.Split(' ');
                        for (int i = 0; i < points.Count(); i = i + 2)
                        {
                            polyline.Locations.Add(new Location(double.Parse(points[i], CultureInfo.InvariantCulture), double.Parse(points[i + 1], CultureInfo.InvariantCulture)));
                        }

                        Map.Children.Add(polyline);
                    }

                    if (txt.area != null && txt.area.Circle != null)
                    {
                        var Circle             = new MapPolyline();
                        Circle.StrokeThickness = 2;
                        Circle.Stroke          = new SolidColorBrush(color);
                        Circle.Locations       = CalculateCircle((double)txt.area.Circle.position.lat, (double)txt.area.Circle.position.lon, txt.area.Circle.radius);
                        Map.Children.Add(Circle);
                    }
                }
            });
        }
        /// <summary>
        /// add new lines on the map
        /// </summary>
        /// <param name="area"></param>
        void addNewPolyline(string area)
        {
            MapPolyline polyline;
            Random      r = new Random(DateTime.Now.Millisecond);

            Color[] colorArray = new Color[10] {
                System.Windows.Media.Colors.Red, System.Windows.Media.Colors.Green, System.Windows.Media.Colors.Blue
                , System.Windows.Media.Colors.White, System.Windows.Media.Colors.Black, System.Windows.Media.Colors.Purple
                , System.Windows.Media.Colors.Orange, System.Windows.Media.Colors.Yellow, System.Windows.Media.Colors.Gray
                , System.Windows.Media.Colors.Gold
            };

            var a = bl.GetAllLineGroupByArea().ToList();

            int j = 0;

            for (int i = 0; i < a.Count(); i++)
            {
                if (area == "all areas" || a[i].First().Area == area)
                {
                    Color colorPolyLine = new Color();
                    Color colorPin      = new Color();
                    colorPin = colorArray[i % 10];
                    foreach (BO.Line line in a[i].ToList())
                    {
                        polyline = new MapPolyline();
                        polyline.StrokeThickness = 5;
                        polyline.Opacity         = 1;
                        colorPolyLine            = colorArray[j % 10];
                        polyline.Stroke          = new System.Windows.Media.SolidColorBrush(colorPolyLine);

                        polyline.Locations = new LocationCollection();

                        foreach (BO.Stop stop in bl.GetAllStopsByLineNumber(line.Number))
                        {
                            Location pinLocation = new Location();
                            pinLocation.Latitude  = stop.Latitude;
                            pinLocation.Longitude = stop.Longitude;

                            Pushpin pin = new Pushpin();
                            pin.Background = new SolidColorBrush(colorPin);
                            pin.Location   = pinLocation;

                            myMap.Children.Add(pin);
                            polyline.Locations.Add(pin.Location);
                        }
                        myMap.Children.Add(polyline);
                        j++;
                    }
                }
            }
        }
Exemplo n.º 21
0
        public static void AddRoute(string routeXml, Color color)
        {
            Map.Dispatcher.Invoke(() =>
            {
                Route rtz = null;

                try
                {
                    rtz = Serialization.Deserialize <Route>(routeXml);
                }
                catch (Exception)
                {
                }

                if (rtz != null)
                {
                    MapPolyline polyline     = new MapPolyline();
                    polyline.Stroke          = new SolidColorBrush(color);
                    polyline.StrokeThickness = 2;
                    polyline.Opacity         = 0.7;

                    polyline.Locations = new LocationCollection();
                    foreach (var waypoint in rtz.waypoints.waypoint)
                    {
                        polyline.Locations.Add(new Location((double)waypoint.position.lat, (double)waypoint.position.lon));
                    }

                    Map.Children.Add(polyline);

                    var lable        = new System.Windows.Controls.TextBlock();
                    lable.Text       = rtz.routeInfo.routeName;
                    lable.Foreground = new SolidColorBrush(color);
                    lable.FontSize   = 12;
                    lable.FontWeight = System.Windows.FontWeights.Bold;
                    Map.AddChild(lable, polyline.Locations[0]);

                    //Add pushpin for first waypoint
                    var pos      = rtz.waypoints.waypoint.FirstOrDefault().position;
                    Pushpin pin  = new Pushpin();
                    pin.Location = new Location((double)pos.lat, (double)pos.lon);
                    pin.ToolTip  = pos.lat + " " + pos.lon + " " + rtz.waypoints.waypoint.FirstOrDefault().name;
                    Map.Children.Add(pin);

                    //Add pushpin for last waypoint
                    pos          = rtz.waypoints.waypoint.LastOrDefault().position;
                    pin          = new Pushpin();
                    pin.Location = new Location((double)pos.lat, (double)pos.lon);
                    pin.ToolTip  = pos.lat + " " + pos.lon + " " + rtz.waypoints.waypoint.LastOrDefault().name;
                    Map.Children.Add(pin);
                }
            });
        }
Exemplo n.º 22
0
        private async void UpdateRoute(Pushpin StartPin, Pushpin EndPin)
        {
            RouteLayer.Children.Clear();

            var startCoord = LocationToCoordinate(StartPin.Location);
            var endCoord   = LocationToCoordinate(EndPin.Location);

            var response = await BingMapsRESTToolkit.ServiceManager.GetResponseAsync(new BingMapsRESTToolkit.RouteRequest()
            {
                Waypoints = new List <BingMapsRESTToolkit.SimpleWaypoint>()
                {
                    new BingMapsRESTToolkit.SimpleWaypoint(startCoord),
                    new BingMapsRESTToolkit.SimpleWaypoint(endCoord)
                },
                BingMapsKey  = SESSION_KEY,
                RouteOptions = new BingMapsRESTToolkit.RouteOptions()
                {
                    RouteAttributes = new List <BingMapsRESTToolkit.RouteAttributeType>
                    {
                        BingMapsRESTToolkit.RouteAttributeType.RoutePath
                    }
                }
            });

            if (response != null &&
                response.ResourceSets != null &&
                response.ResourceSets.Length > 0 &&
                response.ResourceSets[0].Resources != null &&
                response.ResourceSets[0].Resources.Length > 0)
            {
                var route = response.ResourceSets[0].Resources[0] as BingMapsRESTToolkit.Route;

                var locs = new LocationCollection();

                for (var i = 0; i < route.RoutePath.Line.Coordinates.Length; i++)
                {
                    locs.Add(new Location(route.RoutePath.Line.Coordinates[i][0], route.RoutePath.Line.Coordinates[i][1]));
                }

                Random random = new Random();
                System.Windows.Media.Color randomColor = System.Windows.Media.Color.FromArgb(255, (byte)random.Next(0, 256), (byte)random.Next(0, 256), (byte)random.Next(0, 256));

                var routeLine = new MapPolyline()
                {
                    Locations       = locs,
                    Stroke          = new SolidColorBrush(randomColor),
                    StrokeThickness = 3
                };

                RouteLayer.Children.Add(routeLine);
            }
        }
        private void UbicarmeClick(object sender, RoutedEventArgs e)
        {
            Pushpin ubicarme = new Pushpin();

            try
            {
                ubicarme.GeoCoordinate        = new GeoCoordinate(la, lo);
                this.mapWithMyLocation.Center = ubicarme.GeoCoordinate;
            }
            finally
            {
            }
        }
        // the method adds a pushpin at the location of the kinect hand position (preferrably right hand)
        // the kinectHandPositionOnScreen has a default value of 0,0. It gets updated based on hand position.
        private void ShowLocationOfKinectHandPoint()
        {
            // The kinectHandPositionOnScreen gives coordinates relative to the UIElement on which kinect hands are drawn which in this case is 'KinectCanvas'.
            // This coordinates needs to translated relative to the Map UIElement to find out the location.
            System.Windows.Point mapPoint = KinectCanvas.TranslatePoint(kinectHandPositionOnScreen, myMap);
            // Due to some alignment problem, the Y coordinate is shifted (Open Issue: need to figure out the problem). Hence this offset tries to place the point exactly on the kinect hand position
            mapPoint.Y = mapPoint.Y - StaticVariables.handPointOffsetY;
            Microsoft.Maps.MapControl.WPF.Location l = myMap.ViewportPointToLocation(mapPoint);
            Pushpin pushpin = new Pushpin();

            pushpin.Location = l;
            myMap.Children.Add(pushpin);
        }
Exemplo n.º 25
0
        public Pushpin AddPushpin(IMappablePoint point)
        {
            // create a pin and set it's position...
            var pin = new Pushpin();
            pin.Text = point.Name;
            MapLayer.SetPosition(pin, point.ToLocation());

            // ...then add it...
            this.InnerMap.Children.Add(pin);

            // return...
            return pin;
        }
 public void CreatePin(Location key)
 {
     if (key != null)
     {
         pin[key] = new Pushpin()
         {
             Heading    = -45,
             Background = new SolidColorBrush(Colors.Red),
             Content    = "+",
             Location   = key,
         };
     }
 }
Exemplo n.º 27
0
        private void LoadPosition()
        {
            myMap.ZoomLevel = 18;
            myMap.Center    = coordinate;

            pushpin            = new Pushpin();
            pushpin.Background = new SolidColorBrush(Colors.Red);

            layer = new MapLayer();
            layer.Children.Add(pushpin);
            MapLayer.SetPosition(pushpin, coordinate);
            myMap.Children.Add(layer);
        }
        public override Pushpin RenderEntity(Entity entity)
        {
            var p = new Pushpin();

            MapLayer.SetPosition(p, entity.Location);
            p.Tag     = entity;
            p.ToolTip = new ToolTip()
            {
                Content = (entity as CustomEntity).Title
            };

            return(p);
        }
        private Pushpin createOriginPin(FlightRoute item)
        {
            Pushpin originPin = new Pushpin();

            originPin.Background = Brushes.Green;
            originPin.Location   = new Location();

            originPin.Location.Latitude  = item.latOrigin;
            originPin.Location.Longitude = item.lonOrigin;
            originPin.ToolTip            = item.originName;

            return(originPin);
        }
Exemplo n.º 30
0
        private void PushpinTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            //ignoreMapTap = true;
            Pushpin     pushpin = (sender as Pushpin);
            PlaceHelper place   = places.Where(p => p.position == pushpin.Location).FirstOrDefault();

            this.DataContext = place;
            if (NavigationService.CanGoBack)
            {
                PhoneApplicationService.Current.State["place"] = place;
                NavigationService.GoBack();
            }
        }
Exemplo n.º 31
0
        private Pushpin AddPin(GeoCoordinate location, string tooltip, Color color)
        {
            var pin = new Pushpin
            {
                Cursor     = Cursors.Hand,
                Background = new SolidColorBrush(color)
            };

            ToolTipService.SetToolTip(pin, tooltip);
            ToolTipService.SetInitialShowDelay(pin, 0);
            layer.AddChild(pin, new Location(location.Latitude, location.Longitude));
            return(pin);
        }
        /// <summary>
        /// show Location
        /// </summary>
        private void showLoc()
        {
            Location pinLocation = new Location();

            pinLocation.Latitude  = latitude;
            pinLocation.Longitude = longitude;

            Pushpin pin = new Pushpin();

            pin.Location = pinLocation;

            myMap.Children.Add(pin);
        }
Exemplo n.º 33
0
 private void InitializeMapPinsAndCenter()
 {
     foreach (var cityModel in _viewModel.Cities)
     {
         var pushpin = new Pushpin();
         pushpin.Name       = cityModel.CityName;
         pushpin.MouseDown += Pushpin_OnMouseDown;
         pushpin.Location   = new Location(cityModel.Latitude, cityModel.Longitude);
         mapView._map.Children.Add(pushpin);
     }
     mapView._map.Center    = new Location(59.334415, 18.110103);
     mapView._map.ZoomLevel = 5;
 }
 private void AddPinsToMap()
 {
     if (ViewModel.Lat != null && ViewModel.Lon != null)
     {
         Pushpin pushpin = new Pushpin();
         OlaWinMap.Center = new Location(Convert.ToDouble(ViewModel.Lat), Convert.ToDouble(ViewModel.Lon));
         //pushpin.Text = "You are here";
         pushpin.Width = 100;
         pushpin.Height = 100;
         MapLayer.SetPosition(pushpin, OlaWinMap.Center);
         OlaWinMap.Children.Add(pushpin);
     }
 }
Exemplo n.º 35
0
 /// <summary>
 /// Show popup messages
 /// </summary>
 private async void pushpinTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
 {
     Pushpin           pushpin = (Pushpin)sender;
     OBJ_Establishment oEst    = (OBJ_Establishment)pushpin.Tag;
     MessageDialog     dialog  = new MessageDialog("Comercio: " + oEst.estName + "\n" +
                                                   "Email: " + oEst.estEmail + "\n" +
                                                   "Estatus: " + oEst.estStatus + "\n" +
                                                   "Dirección: " + oEst.estAddPhysical1 + "\n" +
                                                   "                 " + oEst.estAddPhysical2 + "\n" +
                                                   "                 " + oEst.estAddPhysicalCity + ", " + oEst.estAddPhysicalState + ", " + oEst.estAddPhysicalZipCode + "\n"
                                                   );
     await dialog.ShowAsync();
 }
Exemplo n.º 36
0
        public MapPage()
        {
            InitializeComponent();
            map1.CredentialsProvider = new ApplicationIdCredentialsProvider("AonkIkqWjK4vVWhc5Cvm9ARnaTGsh-V3eOUrPK2fHxgGNKVgsyclGktq1RDQQXSV");
            Pushpin p = new Pushpin();

            p.Background = new SolidColorBrush(Colors.Yellow);
            p.Foreground = new SolidColorBrush(Colors.Black);
            p.Location   = new GeoCoordinate(17.451356, 78.380735);
            p.Content    = "You are here";
            map1.Children.Add(p);
            map1.SetView(new GeoCoordinate(10, 10, 20), 2);
        }
Exemplo n.º 37
0
        private void LoadPosition()
        {
            myMap.ZoomLevel = 18;
            myMap.Center = coordinate;

            pushpin = new Pushpin();
            pushpin.Background = new SolidColorBrush(Colors.Red);

            layer = new MapLayer();
            layer.Children.Add(pushpin);
            MapLayer.SetPosition(pushpin, coordinate);
            myMap.Children.Add(layer);
        }
Exemplo n.º 38
0
        private Pushpin AddPin(Location location, string tooltip, Color color, object typeOfObject)
        {
            var pin = new Pushpin();

            pin.Cursor     = Cursors.Hand;
            pin.Background = new SolidColorBrush(color);
            pin.Tag        = typeOfObject;
            ToolTipService.SetToolTip(pin, tooltip);
            ToolTipService.SetInitialShowDelay(pin, 0);
            layer.AddChild(pin, new Location(location.Latitude, location.Longitude));
            pushpins.Add(pin);
            return(pin);
        }
        /// <summary>
        /// update the list of Report record and push the graphic "pins" for them in the map
        /// </summary>
        /// <param name="item"></param>
        public void updateReportsAndPushPins(Report item)
        {
            Pushpin  pin          = new Pushpin();
            Location tempLocation = new Location();

            Reports.Add(item);
            tempLocation.Latitude  = item.Latitude;
            tempLocation.Longitude = item.Longitude;
            pin.Location           = tempLocation;
            pin.Background         = new SolidColorBrush(ToMediaColor(System.Drawing.Color.FromName("Blue")));
            pushpins.Add(pin);
            //pushpins.CollectionChanged += PushpinCollectionChange;
        }
Exemplo n.º 40
0
        // get the coordinates
        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            //parse the item the user selected
            string[] words = listBox1.SelectedItem.ToString().Split(':');
            // get coordinates
            BusinessTier.Coordinates coord = bt.getCoordinates(Convert.ToInt32(words[0]));

            // display coordinates
            string newMsg = string.Format("({1},{0})", coord.Longitude, coord.Latitude);

            this.textBox1.Text = newMsg;

            //Display the location via a pin and center it on the map
            Pushpin pin = new Pushpin();

            pin.Location = new Location(coord.Latitude, coord.Longitude);
            theMap.map.Children.Add(pin);
            theMap.map.Center = new Location(coord.Latitude, coord.Longitude);
            theMap.map.Focus();
            elementHost1.Child = theMap;

            // Add event handler to push pin
            pin.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(pin_MouseRightButtonDown);

            // now get the stops at this station
            IReadOnlyList <BusinessTier.Stops> lines  = bt.getAllStopsbyStationID(Convert.ToInt32(words[0]));
            IEnumerator <BusinessTier.Stops>   lineEn = lines.GetEnumerator();

            BusinessTier.Stops curLine;

            // if listbox contains items. then clear it
            if (listBox2.Items.Count != 0)
            {
                listBox2.Items.Clear();
            }


            // format the content
            while (lineEn.MoveNext())
            {
                curLine = lineEn.Current;
                string msg = string.Format(" {0}: {1}", curLine.StopID, curLine.Name);
                this.listBox2.Items.Add(msg); // once formatted , add it to listbox2
            }


            // total riderships and average per day
            BusinessTier.Sum_Avg myResult = bt.totalRiders(Convert.ToInt32(words[0]));
            this.textBox4.Text = Convert.ToString(myResult.Sum);
            this.textBox5.Text = Convert.ToString(myResult.Average);
        }
Exemplo n.º 41
0
        private void ULPins_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            Pushpin[] temp = this.Children.Cast <object>().Where(p => p is Pushpin).Cast <Pushpin>().ToArray().Clone() as Pushpin[];

            if (e.OldItems != null)
            {
                //foreach (UserLocation ul in e.OldItems)
                //    this.Children.Remove(temp.FirstOrDefault(p => p.ToolTip == ul.Name));
                clearPins();
                foreach (var pin in temp)
                {
                    if (e.OldItems.Cast <UserLocation>().Any(p => p.Name == (string)((ToolTip)pin?.ToolTip)?.Content))
                    {
                        continue;
                    }
                    Pushpin np = new Pushpin()
                    {
                        Location = pin.Location, Content = pin.Content
                    };
                    np.ToolTip = pin.ToolTip;
                    this.Children.Add(np);
                }
            }


            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset)
            {
                foreach (Pushpin pin in temp)
                {
                    if (!Pins?.Any(p => p.Location == pin.Location) ?? false)
                    {
                        this.Children.Remove(pin);
                    }
                }
            }

            //Add the new pushpins
            if (e.NewItems != null)
            {
                foreach (UserLocation ul in e.NewItems)
                {
                    Pushpin np = new Pushpin()
                    {
                        Location = ul.Pin.Location, Content = Tools.CreateIcon(MaterialDesignThemes.Wpf.PackIconKind.Star)
                    };
                    np.ToolTip = Tools.CreateTootip(ul.Name);
                    this.Children.Add(np);
                }
            }
            this.UpdateLayout();
        }
Exemplo n.º 42
0
        public MainWindow()
        {
            InitializeComponent();
            //this.map.Mode = new MercatorMode();
            //this.map.Children.Add(new AMapTitleLayer());
            //this.map.MouseDown += Map_MouseDown;
            var pushpins = new List <PushpinModel>();

            pushpins.Add(new PushpinModel {
                ID = 1, Location = new Location(39.8151940395589, 116.411970893135), Title = "和义东里社区"
            });
            pushpins.Add(new PushpinModel {
                ID = 2, Location = new Location(39.9094878843105, 116.33299936282), Title = "中国水科院南小区"
            });
            pushpins.Add(new PushpinModel {
                ID = 3, Location = new Location(39.9219204792284, 116.203500574855), Title = "石景山山姆会员超市"
            });
            pushpins.Add(new PushpinModel {
                ID = 4, Location = new Location(39.9081417418219, 116.331244439925), Title = "茂林居小区"
            });
            PushpinArray = pushpins;

            _polyLocations = new LocationCollection();
            //_polyLocations.Add(new Location(39.9082973053021, 116.63105019548));
            //_polyLocations.Add(new Location(39.9155572462212, 116.192505993178));
            //_polyLocations.Add(new Location(39.8065773542251, 116.276113341099));
            _polyLocations.Add(new Location(39.9082973053021, 116.63105019548));
            _polyLocations.Add(new Location(31.9121578992881, 107.233555852083));

            mapPolyline = new MapPolyline
            {
                Stroke          = Brushes.Green,
                StrokeThickness = 2,
                Locations       = _polyLocations,
            };
            CarLayer.Children.Add(mapPolyline);

            carPushpin = new Pushpin
            {
                Template = this.Resources["CarTemplate"] as ControlTemplate,
                //Location = new Location(39.9082973053021, 116.63105019548),//_polyLocations[0],
                Location       = new Location(31.9121578992881, 107.233555852083),
                PositionOrigin = PositionOrigin.Center,
            };

            CarLayer.Children.Add(carPushpin);

            dispatcherTimer          = new DispatcherTimer();
            dispatcherTimer.Interval = TimeSpan.FromSeconds(1.5);
            dispatcherTimer.Tick    += DispatcherTimer_Tick;
        }
Exemplo n.º 43
0
        public void SetUserLocation(Microsoft.Maps.MapControl.WPF.Location newLocation)
        {
            Pushpin newPin = new Pushpin()
            {
                Location   = newLocation,
                Content    = "YOU ARE HERE",
                Background = Brushes.DarkOrange,
                Foreground = Brushes.DarkOrange,
                FontSize   = 1
            };

            newPin.MouseEnter += NewPin_MouseEnter;
            newMap.Children.Add(newPin);
        }
Exemplo n.º 44
0
        private void miMapa_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            e.Handled = true;
            var mousePosicion = e.GetPosition((UIElement)sender);

            puntoUbicacion = miMapa.ViewportPointToLocation(mousePosicion);

            Pushpin marcador = new Pushpin();

            marcador.Location = puntoUbicacion;

            miMapa.Children.Clear();
            miMapa.Children.Add(marcador);
        }
Exemplo n.º 45
0
 private async void GetMyLocation()
 {
     var geolocator = new Windows.Devices.Geolocation.Geolocator();
     Geoposition myGeoposition = await geolocator.GetGeopositionAsync();
     Location mylocation = new Location(myGeoposition.Coordinate.Latitude, myGeoposition.Coordinate.Longitude);
     // Make my current location the center of the Map.
     this.MyMap.Center = mylocation;
     this.MyMap.ZoomLevel = 15;
     //Create a small shape to mark the current location.
     Pushpin pushpin = new Pushpin();
     pushpin.Text = "S";
     MapLayer.SetPosition(pushpin, mylocation);
     MyMap.Children.Add(pushpin);
 }
Exemplo n.º 46
0
        public MapPage ()
        {
            this.InitializeComponent ();
            map.Credentials = Constants.BingMapsKey;

            locator = new Geolocator ();
            popup = new MapPopup ();

            userPin = new Pushpin ();
            userPin.Tapped += OnPinTapped;

            DataContext =
                assignmentViewModel = ServiceContainer.Resolve<AssignmentViewModel> ();
        }
Exemplo n.º 47
0
 private async void HotelLocation()
 {
     var geolocator = new Windows.Devices.Geolocation.Geolocator();
     Geoposition myGeoposition = await geolocator.GetGeopositionAsync();
     Location mylocation = new Location(NW.mylist[key].Latitude, NW.mylist[key].Longitude);
     // Make my current location the center of the Map.
     this.HotelMap.Center = mylocation;
     this.HotelMap.ZoomLevel = 15;
     //Create a small shape to mark the current location.
     Pushpin pushpin = new Pushpin();
     pushpin.Text = "HERE";
     MapLayer.SetPosition(pushpin, mylocation);
     HotelMap.Children.Add(pushpin);
 }
 void Pin_Tapped(object sender, TappedRoutedEventArgs e)
 {
     System.Diagnostics.Debug.WriteLine("PIN TAPPED");
     Pushpin pp = (Pushpin)sender;
     foreach (Place p in placeList)
     {
         if (p.PlaceData.Name == pp.Name)
         {
             MyOverlay.setTitle(p.PlaceData.Title);
             MyOverlay.setDescription(p.PlaceData.Description);
             MyOverlay.Visibility = Windows.UI.Xaml.Visibility.Visible;
         }
     }
 }
Exemplo n.º 49
0
        // popup constructor for showing user ratings in another listbox
        // after a user double-clicks a user in the output listbox
        public Form2(Pushpin pin, BusinessTier.Business bt)
        {
            InitializeComponent();

              Location loc = pin.Location;

              double latitude = loc.Latitude;
              double longitude = loc.Longitude;

              // now get the stops at this location
              IReadOnlyList<BusinessTier.Stops> lines = bt.getAllStopsbyLocation(latitude, longitude);
              IEnumerator<BusinessTier.Stops> lineEn = lines.GetEnumerator();

              BusinessTier.Stops curLine;

              // format the content
              while (lineEn.MoveNext())
              {
            string stopMsg;
            string coordinates;
            string handicap;

            curLine = lineEn.Current;
            stopMsg = string.Format(" {0}: {1}", curLine.StopID, curLine.Name);

            // get stop info
            BusinessTier.Stops stopInfo = bt.getStopInfo(Convert.ToInt32(curLine.StopID));

            // display coordinates of stop
            coordinates = string.Format("({1},{0})", stopInfo.Longitude, stopInfo.Latitude);

            // handicap accessible ?
            if (stopInfo.ADA == 0)
            {
              handicap = "No";
            }
            else
            {
              handicap = "Yes";
            }

            this.pushPin_listBox.Items.Add(stopMsg);
            this.pushPin_listBox.Items.Add("Location: " + coordinates);
            this.pushPin_listBox.Items.Add("Handicap Accessible: " + handicap);
            this.pushPin_listBox.Items.Add("Direction: " + stopInfo.Direction);
            this.pushPin_listBox.Items.Add("Stop Detail: " + bt.getDetail(stopInfo.StopID));
            this.pushPin_listBox.Items.Add("");
              }
        }
Exemplo n.º 50
0
    void Client_GetTimeCompleted(object sender, HydroNumerics.Time.Web.TimeSeriesService.GetTimeCompletedEventArgs e)
    {
      TheChart.DataContext = e.Result.First();
      TheGrid.DataContext = e.Result.First().items;

      foreach (var v in e.Result)
      {
        Pushpin p = new Pushpin();
        p.Location = new Location(v.Geometry.X, v.Geometry.Y);
        p.Tag = v;
        p.MouseLeftButtonUp += new MouseButtonEventHandler(p_MouseLeftButtonUp);
        TheMap.Children.Add(p);

        }
    }
Exemplo n.º 51
0
        private void Pushpin_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var pushpin = sender as Pushpin;
            SelectedItem = pushpin.DataContext;

            if (_selectedPushpin != null)
            {
                _selectedPushpin.Content = null;
                _selectedPushpin.UpdateLayout();
            }

            _selectedPushpin = pushpin;
            _selectedPushpin.Content = new Ellipse() { Width = 13, Height = 13, Fill = new SolidColorBrush(Colors.Blue) };
            _selectedPushpin.UpdateLayout();
        }
Exemplo n.º 52
0
 async void dt_Tick(object sender, object e)
 {
     
     //Location location;
      Location location;
     var taskassign = await emp.Where(p => p.busno == t1.Text).ToListAsync();
     f = Convert.ToDouble(taskassign[0].latttitude);
     g = Convert.ToDouble(taskassign[0].lonngitude);
     location = new Location(f,g);
     myMap.ShowBuildings = true;
     myMap.ShowTraffic = true;
     Pushpin pushpin = new Pushpin();
     MapLayer.SetPosition(pushpin, location);
     myMap.Children.Add(pushpin);
     myMap.SetView(location);
 }
Exemplo n.º 53
0
 public LocationSelector(double lat, double lon)
 {
     InitializeComponent();
     var center = new Location();
     center.Latitude = lat;
     center.Longitude = lon;
     Map.Center = center;
     Map.ZoomLevel = 15;
     pin = new Pushpin();
     pin.Location = Map.Center;
     Map.Children.Add(pin);
     Map.MouseUp += delegate(object sender, MouseButtonEventArgs e)
     {
         var mousePosition = e.GetPosition(this);
         pin.Location = Map.ViewportPointToLocation(mousePosition);
     };
 }
Exemplo n.º 54
0
        // get the coordinates
        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            //parse the item the user selected
            string[] words = listBox1.SelectedItem.ToString().Split(':');
            // get coordinates
            BusinessTier.Coordinates coord = bt.getCoordinates(Convert.ToInt32(words[0]));

            // display coordinates
            string newMsg = string.Format("({1},{0})", coord.Longitude, coord.Latitude);
            this.textBox1.Text = newMsg;

            //Display the location via a pin and center it on the map
            Pushpin pin = new Pushpin();
            pin.Location = new Location(coord.Latitude, coord.Longitude);
            theMap.map.Children.Add(pin);
            theMap.map.Center = new Location(coord.Latitude, coord.Longitude);
            theMap.map.Focus();
            elementHost1.Child = theMap;

            // Add event handler to push pin
            pin.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(pin_MouseRightButtonDown);

              // now get the stops at this station
              IReadOnlyList<BusinessTier.Stops> lines = bt.getAllStopsbyStationID(Convert.ToInt32(words[0]));
            IEnumerator<BusinessTier.Stops> lineEn = lines.GetEnumerator();

            BusinessTier.Stops curLine;

            // if listbox contains items. then clear it
            if (listBox2.Items.Count != 0) { listBox2.Items.Clear(); }

            // format the content
            while (lineEn.MoveNext())
            {
                curLine = lineEn.Current;
                string msg = string.Format(" {0}: {1}", curLine.StopID, curLine.Name);
                this.listBox2.Items.Add(msg); // once formatted , add it to listbox2
            }

            // total riderships and average per day
            BusinessTier.Sum_Avg myResult = bt.totalRiders(Convert.ToInt32(words[0]));
            this.textBox4.Text = Convert.ToString(myResult.Sum);
            this.textBox5.Text = Convert.ToString(myResult.Average);
        }
Exemplo n.º 55
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            Geolocator geolocator = new Geolocator();
            var geo = await geolocator.GetGeopositionAsync();

            MapControl.Center = new Location(geo.Coordinate.Latitude, geo.Coordinate.Longitude);
            MapControl.ZoomLevel = 15;

            Pushpin pushpin = new Pushpin();
            pushpin.Text = "1";

            MapLayer.SetPosition(pushpin, new Location(geo.Coordinate.Latitude, geo.Coordinate.Longitude));


            List<Locations> locations = await locationsController.GetLocations();

            AddPins(locations);
            
        }
Exemplo n.º 56
0
        private void Click_AddPins(object sender, MouseButtonEventArgs e)
        {
            // Disables the default mouse action.
            e.Handled = true;

            // Determin the location to place the pushpin at on the map.
            // Get the mouse click coordinates
            Point mousePosition = e.GetPosition(this);

            // Convert the mouse coordinates to a locatoin on the map
            Location pinLocation = myMap.ViewportPointToLocation(mousePosition);
            Console.WriteLine("location {0}", pinLocation);

            // The pushpin to add to the map.
            Pushpin pin = new Pushpin();
            pin.Location = pinLocation;

            // Adds the pushpin to the map.
            myMap.Children.Add(pin);

            // Add error checking here (is the pin in the correct place? Try again)

            MessageBoxResult result1 = MessageBox.Show("Place event here?", "Place Event", MessageBoxButton.YesNo);

            if (result1 == MessageBoxResult.Yes)
            {
                // Send pin location details to event details page
                EventDetails myEventDetails = new EventDetails();
                myEventDetails.cordLatTb.Text = pinLocation.Latitude + "";
                myEventDetails.cordLongTb.Text = pinLocation.Longitude + "";

                //Send Active User to EventDetails Page
                myEventDetails.activeUserLabel.Content = activeUserLabel.Content.ToString();

                // Navigate to event details page
                this.NavigationService.Navigate(myEventDetails);
            }
            else
            {
                myMap.Children.Remove(pin);

            }
        }
Exemplo n.º 57
0
        public GeoTagEditorView()
        {
            InitializeComponent();
            
            map.CredentialsProvider = new ApplicationIdCredentialsProvider(BingMapsKey.Key);
            map.PreviewMouseDoubleClick += map_PreviewMouseDoubleClick;
            map.PreviewMouseWheel += map_PreviewMouseWheel;
            
            map.CredentialsProvider.GetCredentials((c) =>
            {
                BingMapsKey.SessionKey = c.ApplicationId;
            });

            Pin = new Pushpin();
            Pin.ToolTip = "Finding Location...";
            Pin.ToolTipOpening += Pin_ToolTipOpening;

            IsToolTipLocationSet = false;
        }
Exemplo n.º 58
0
        public MainPage()
        {
            this.InitializeComponent();
            this.monitor = GeofenceMonitor.Current;

            currentLocationPushpin = new Pushpin();
            currentLocationPushpin.Background = new SolidColorBrush(Colors.Black);
          
            myMap.Children.Add(currentLocationPushpin);
            
            loader = new GeofenceLoader(new Uri("http://localhost:1337"));
            loader.PropertyChanged += loader_PropertyChanged;

            monitor = GeofenceMonitor.Current;

            locator = new Geolocator();
            locator.MovementThreshold = 10;
            locator.PositionChanged += locator_PositionChanged;
        }
Exemplo n.º 59
0
        private static void OnGeocodeResultChanged(Map map, BingMapsService.GeocodeResult oldValue, BingMapsService.GeocodeResult newValue)
        {
            Location location = newValue.Locations.Select(x => new Location(x.Latitude, x.Longitude)).First();

            Pushpin pin = new Pushpin();
            pin.Location = location;
            pin.ToolTip = newValue.Address.FormattedAddress;

            var locationLayer = GetGeocodeResultLayer(map);
            if (locationLayer == null)
            {
                locationLayer = new MapLayer();
                SetGeocodeResultLayer(map, locationLayer);
            }

            locationLayer.Children.Clear();
            locationLayer.Children.Add(pin);

            map.SetView(location, map.ZoomLevel);
        }
Exemplo n.º 60
0
		void geo_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
		{
			var latvar = args.Position.Coordinate.Latitude;
			var longvar = args.Position.Coordinate.Longitude;

			this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
			{
				MyMap.Center = new Location(latvar, longvar);
				MyMap.ZoomLevel = 12;

				var pushpin = new Pushpin
				{
					Text = "@"
				};
				MapLayer.SetPosition(pushpin, new Location(latvar, longvar));
				MyMap.Children.Add(pushpin);

				UpdateGeoButton.IsEnabled = true; //unlock when completed
			});
		}