Exemplo n.º 1
0
 public UserPinPage()
 {
     InitializeComponent();
     _userPin = (UserPin)DataContext;
     if (_userPin.Image != null)
     {
         return;
     }
     _userPin.Image = GoogleMapsServices.GetStaticMap(_userPin.Location, 15, new Models.GoogleMaps.Size { Width = 125, Height = 125 });
 }
Exemplo n.º 2
0
        public UserPushpinContent()
        {
            DefaultStyleKey = typeof(UserPushpinContent);
            _userPin = DataContext as UserPin;

            if (_userPin == null) return;
            if (_userPin.Address == null) GoogleMapsServices.GetPlaceDetails(_userPin.Location, places =>
            {
                if (places == null || places.Count() == 0)
                {
                    return;
                }
                _userPin.Address = places.First().FormattedAddress;
            });

            VisualStateManager.GoToState(this, IsExpanded ? "Expanded" : "Collapsed", true);
            GestureService.GetGestureListener(this).Hold += (s, e) => e.Handled = true;
        }
Exemplo n.º 3
0
        private void ShowSearchResults(IEnumerable<Place> places)
        {
            ProgressBar.IsIndeterminate = false;
            _mainViewModel.EditingUserPin = null;
            var collection = new LocationCollection();
            int colorIndex = _rdm.Next(SettingsViewModel.AvailablePushpinColors.Count - 1), i = 0;
            var color = SettingsViewModel.AvailablePushpinColors[SettingsViewModel.AvailablePushpinColors.Keys.First(key => i++ == colorIndex)];

            foreach (var l in places)
            {
                var p = new UserPin
                {
                    Location = l.Geometry.Location,
                    Title = String.IsNullOrEmpty(l.Name) ? "My Search" : l.Name,
                    IsTemporary = true,
                    Color = color,
                    Key = Guid.NewGuid()
                };

                if (l is PlaceDetails)
                {
                    p.Address = ((PlaceDetails) l).FormattedAddress;
                }
                else if (Globals.IsNetworkAvailable)
                {
                    GoogleMapsServices.GetPlaceDetails(
                        l.Geometry.Location,
                        reverseGeocodeResults =>
                        {
                            if (reverseGeocodeResults != null && reverseGeocodeResults.Count() > 0)
                            {
                                p.Address = reverseGeocodeResults.First().FormattedAddress;
                            }
                        });
                }

                p.Image = GoogleMapsServices.GetStaticMap(
                    p.Location,
                    15,
                    new Size {Width = 125, Height = 125});
                _mainViewModel.TemporaryPins.Add(p);
                if (l.Geometry.ViewPort == null)
                {
                    collection.Add(p.Location);
                }
                else
                {
                    var viewPort = l.Geometry.ViewPort;
                    collection.Add(viewPort.NorthEast);
                    collection.Add(viewPort.SouthWest);
                }
            }
            Map.SetView(LocationRect.CreateLocationRect(collection));
        }
Exemplo n.º 4
0
        private void ShowSearchResult(Place place)
        {
            ProgressBar.IsIndeterminate = false;
            _mainViewModel.EditingUserPin = null;
            int colorIndex = _rdm.Next(SettingsViewModel.AvailablePushpinColors.Count - 1), i = 0;
            var color = SettingsViewModel.AvailablePushpinColors[SettingsViewModel.AvailablePushpinColors.Keys.First(key => i++ == colorIndex)];
            var p = new UserPin
            {
                Location = place.Geometry.Location,
                Title = String.IsNullOrEmpty(place.Name) ? "My Search" : place.Name,
                IsTemporary = true,
                Color = color,
                Key = Guid.NewGuid()
            };
            if (place is PlaceDetails)
            {
                p.Address = ((PlaceDetails) place).FormattedAddress;
            }
            else if (Globals.IsNetworkAvailable)
            {
                GoogleMapsServices.GetPlaceDetails(
                    place.Geometry.Location,
                    reverseGeocodeResults =>
                    {
                        if (reverseGeocodeResults != null && reverseGeocodeResults.Count() > 0)
                        {
                            p.Address = reverseGeocodeResults.First().FormattedAddress;
                        }
                    });
            }

            p.Image = GoogleMapsServices.GetStaticMap(
                p.Location,
                15,
                new Size {Width = 125, Height = 125});
            _mainViewModel.TemporaryPins.Add(p);

            var viewPort = place.Geometry.ViewPort;
            if (viewPort == null)
            {
                Map.SetView(place.Geometry.Location, 15);
            }
            else
            {
                Map.SetView(viewPort);
            }
        }
Exemplo n.º 5
0
 private void CatelogPushpinHyperlinkButtonClick(object sender, RoutedEventArgs e)
 {
     var p = new UserPin
     {
         Location = CatalogPushpin.Location,
         Icon = ((KeyValuePair<string, string>) ((FrameworkElement) sender).DataContext).Value,
         Image = GoogleMapsServices.GetStaticMap(
             CatalogPushpin.Location,
             15,
             new Size {Width = 125, Height = 125})
     };
     if (Globals.IsNetworkAvailable)
     {
         GoogleMapsServices.GetPlaceDetails(p.Location, places =>
         {
             if (places == null || places.Count() == 0)
             {
                 return;
             }
             p.Address = places.First().FormattedAddress;
         });
     }
     _mainViewModel.UserPinLog.Add(p);
     GoToDefaultState();
 }
Exemplo n.º 6
0
 public void Add(UserPin pin)
 {
     pin.Key = Guid.NewGuid();
     Pins.Add(pin);
     Changes.Add(new UserPinChange { Key = pin.Key, Action = UserPinAction.Add });
 }
Exemplo n.º 7
0
 public static bool Equals(UserPin pin1, UserPin pin2)
 {
     return pin1 == pin2 || (pin1 != null && pin2 != null && pin1.Key == pin2.Key);
 }