Exemplo n.º 1
0
        private void MoveLat(int initialBearingRadians)
        {
            var newLocation =
                FindPointAtDistanceFrom(
                    new GeoLocation {
                Latitude = _currentLatitude, Longitude = _currentLongitude
            },
                    initialBearingRadians, 2);

            _currentLatitude = newLocation.Latitude;
            //  _currentLongitude = newLocation.Longitude;
            var mapSpan = MapSpan.FromCenterAndRadius(
                new Position(_currentLatitude, _currentLongitude), Distance.FromKilometers(1));

            TopicsMap.MoveToRegion(mapSpan);
        }
Exemplo n.º 2
0
        async void GetCurrentLocation()
        {
            var location = await CrossGeolocator.Current.GetPositionAsync();

            var mapSpan = MapSpan.FromCenterAndRadius(
                new Position(location.Latitude, location.Longitude), Distance.FromKilometers(1));

            _currentLatitude  = location.Latitude;
            _currentLongitude = location.Longitude;
            TopicsMap.MoveToRegion(mapSpan);


            App.MapPageViewModel.TopicsViewModel.Model.Topics =
                new List <string>(
                    App.MapPageViewModel.TopicsViewModel.Topics.Where(e => !string.IsNullOrEmpty(e.TopicName))
                    .Select(e => e.TopicName));
            App.MapPageViewModel.TopicsViewModel.Model.Coordinates = new GeoCoordinates
            {
                Latitude  = _currentLatitude,
                Longitude = _currentLongitude
            };
            WalkieTalkyClient client = new WalkieTalkyClient();
            var token =
                Services.Services.GetInstance().AccountService.GetAccountFor(App.AppName).Properties["access_token"];
            var response = client.CreatePutRequest(App.MapPageViewModel.TopicsViewModel.Model.PersonId,
                                                   App.MapPageViewModel.TopicsViewModel.Model, token);

            foreach (PersonRecord personRecord in response.ClosePersons)
            {
                if (personRecord.Coordinates.Latitude == null || personRecord.Coordinates.Longitude == null ||
                    string.IsNullOrEmpty(personRecord.Name))
                {
                    continue;
                }
                var item = new Pin
                {
                    Type     = PinType.Generic,
                    Position =
                        new Position(personRecord.Coordinates.Latitude.Value, personRecord.Coordinates.Longitude.Value),
                    Label   = personRecord.Name,
                    Address = personRecord.Phonenumber
                };
                TopicsMap.CustomPins.Add(new CustomPin {
                    Pin = item
                });
                TopicsMap.Pins.Add(item);
            }
            if (response.Match != null)
            {
                string matchedTopicName = string.Empty;
                foreach (Topic topic in App.TopicsViewModel.Topics)
                {
                    foreach (string topicName in response.Match.Topics)
                    {
                        if (topicName.ToUpper().Equals(topic.TopicName.ToUpper()))
                        {
                            matchedTopicName = topicName;
                        }
                    }
                }
                await Navigation.PushModalAsync(new MatchPage(response.Match, matchedTopicName));
            }
        }