Example #1
0
 protected override void OnNavigatedTo(PhoneNavigationEventArgs e)
 {
     ShowLoading();
     _location = LocationHelper.GetCurrentLocation();
     Foursquare.GetCheckIns(GetCheckInsCallback, _location.Latitude, _location.Longitude);
     base.OnNavigatedTo(e);
 }
Example #2
0
 static void geoWatcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
 {
     _locationFromLastGpsUpdate = new Location
     {
         Latitude = _geoWatcher.Position.Location.Latitude,
         Longitude = _geoWatcher.Position.Location.Longitude,
     };
 }
Example #3
0
        public static FrameworkElement AddPushpin(Canvas canvas, Location centerLocation, Location pinLocation, int mapLvl, string text)
        {
            int pixelX = 0;
            int pixelY = 0;
            GeoUtils.LatLongToPixel(centerLocation.Latitude, centerLocation.Longitude, mapLvl, ref pixelX, ref pixelY);
            int offX = pixelX - (int)(canvas.Width / 2);
            int offY = pixelY - (int)(canvas.Height / 2);
            GeoUtils.LatLongToPixel(pinLocation.Latitude, pinLocation.Longitude, 16, ref pixelX, ref pixelY);
            pixelX = pixelX - offX;
            pixelY = pixelY - offY;

            Canvas pinCanvas = new Canvas { Width = 25, Height = 50 };

            // create the pin
            var p = new System.Windows.Shapes.Polygon();
            p.Points = new PointCollection
                               {
                                   new Point(0, 0),
                                   new Point(25, 0),
                                   new Point(25, 25),
                                   new Point(0, 50),
                               };
            p.Fill = new SolidColorBrush(Colors.Black);
            p.Stroke = new SolidColorBrush(Colors.White);
            p.StrokeThickness = 2;
            pinCanvas.Children.Add(p);

            // add the text
            TextBlock txt = new TextBlock();
            txt.Text = text;
            txt.Margin = new Thickness(4, 2, 4, 0);
            txt.Foreground = new SolidColorBrush(Colors.White);
            txt.FontWeight = FontWeights.Bold;
            txt.FontSize = 14;
            pinCanvas.Children.Add(txt);

            pinCanvas.Margin = new Thickness(pixelX, pixelY - 50, 0, 0);
            canvas.Children.Add(pinCanvas);

            return pinCanvas;
        }
 public void GetUserCallback(GetUserCompletedEventArgs e)
 {
     _venue = null;
     if (e.Result.venue != null)
     {
         _venue = e.Result.venue;
         _pinLocation = new Location
             {
                 Latitude = double.Parse(e.Result.venue.geolat),
                 Longitude = double.Parse(e.Result.venue.geolong),
             };
     }
     var model = new FriendDetailViewModel(e.Result);
     DataContext = model;
     if (_pinLocation != null)
     {
         MapHelper.LoadMap(LoadMapCompleted, _pinLocation.Latitude, _pinLocation.Longitude, (int)imageMap.Width,
                           (int)imageMap.Height);
     }
     else
     {
         LayoutRoot.RowDefinitions[2].Height = new GridLength(0);
     }
 }
        private void GetVenuesCallback(GetVenuesCompletedEventArgs e)
        {
            Location location = LocationHelper.GetCurrentLocation();
            int ndx = 1;
            foreach (Venue venue in e.Result)
            {
                var pinLocation = new Location { Latitude = double.Parse(venue.geolat), Longitude = double.Parse(venue.geolong) };
                MapHelper.AddPushpin(canvasMap, location, pinLocation, 16, ndx.ToString());
                ndx++;
            }
            MapHelper.LoadMap(LoadMapCompleted, location.Latitude, location.Longitude,
                  (int)imageMap.Width, (int)imageMap.Height);

            var model = new CheckInChooseVenueViewModel(e.Result);
            this.DataContext = model;
        }
Example #6
0
        private void AddPushpins(IList<CheckIn> checkins)
        {
            if (checkins == null) return;

            for (int i = 0; i < checkins.Count; i++)
            {
                var checkin = checkins[i];
                double latitude, longitude;
                if (checkin == null) continue;
                if (checkin.venue == null) continue;
                if (!double.TryParse(checkin.venue.geolat, out latitude)) continue;
                if (!double.TryParse(checkin.venue.geolong, out longitude)) continue;

                Location pinLocation = new Location { Latitude = double.Parse(checkin.venue.geolat), Longitude = double.Parse(checkin.venue.geolong) };
                FrameworkElement pin = MapHelper.AddPushpin(canvasMap, _location, pinLocation, 16, (i + 1).ToString());
                pin.MouseEnter += PushpinMouseEnter;
                pin.Tag = i;
            }
        }
        private void GetVenueCallback(GetVenueCompletedEventArgs args)
        {
            if (args.Result == null)
            {
                if (args.Error == null || string.IsNullOrEmpty(args.Error.Message))
                {
                    MessageBox.Show("Unknown error");
                    return;
                }
                MessageBox.Show(args.Error.Message);
                return;
            }
            venue = args.Result;
            CheckInButton.IsEnabled = true;

            #region data clean up

            if (string.IsNullOrEmpty(venue.address))
                venue.address = "3950 Las Vegas Blvd S";

            if (string.IsNullOrEmpty(venue.city))
                venue.city = "Las Vegas";

            if(string.IsNullOrEmpty(venue.state))
                venue.state = "NV";

            if(string.IsNullOrEmpty(venue.zip))
                venue.zip = "89119";

            CityStateZip.Text = string.Format("{0}, {1} {2}", venue.city, venue.state, venue.zip);

            if (string.IsNullOrEmpty(venue.phone) && venue.zip == "89119")
                venue.phone = "7026320648";

            if (string.IsNullOrEmpty(venue.twitter) && venue.zip == "89119")
                venue.twitter = "@LVHotels";

            if (!string.IsNullOrEmpty(venue.phone))
                venue.phone = Utilities.FormatPhoneNumber(venue.phone);

            #endregion

            VenueName.Text = venue.name;
            VenueAddress.Text = venue.address;
            CrossStreet.Text = venue.crossstreet;
            Distance.Text = venue.distance;
            Phone.Text = venue.phone;
            Twitter.Text = venue.twitter;

            string distanceStr = Cache.Get("VenueDistance") as string;
            if (distanceStr != null)
            {
                Distance.Text = distanceStr;
            }

            pinLocation = LocationHelper.ToLocation(args.Result.geolat, args.Result.geolong);
            Cache.Set("pinLocation", pinLocation);
            MapHelper.LoadMap(LoadMapCompleted, pinLocation.Latitude, pinLocation.Longitude, (int)imageMap.Width, (int)imageMap.Height);
        }