Exemplo n.º 1
0
        private void GetPlaceFromPicker(Intent data)
        {
            IPlace placePicked  = PlacePicker.GetPlace(Activity, data);
            var    locationText = view.FindViewById <TextView>(Resource.Id.locationText);

            locationText.Text = String.Format("Location:({0},{1})", placePicked.LatLng.Latitude, placePicked.LatLng.Longitude);
            coords            = new GeoCoords(placePicked.LatLng.Latitude, placePicked.LatLng.Longitude);
        }
Exemplo n.º 2
0
        private void GetPlaceFromPicker(Intent data)
        {
            var placePicked = PlacePicker.GetPlace(this, data);

            _placeNameTextView.Text        = placePicked?.NameFormatted?.ToString();
            _placeAddressTextView.Text     = placePicked?.AddressFormatted?.ToString();
            _placePhoneNumberTextView.Text = placePicked?.PhoneNumberFormatted?.ToString();
            _placeWebSiteTextView.Text     = placePicked?.WebsiteUri?.ToString();
        }
Exemplo n.º 3
0
        private void GetPlaceFromPicker(Intent data)
        {
            var placePicked = PlacePicker.GetPlace(this, data);

            selectedLocation  = placePicked?.NameFormatted?.ToString();
            btnPickPlace.Text = selectedLocation;
            selectedLon       = placePicked.LatLng.Longitude;
            selectedLat       = placePicked.LatLng.Latitude;
        }
Exemplo n.º 4
0
        private void GetPlaceFromPicker(Intent data)
        {
            //  taskCompletionSource = new TaskCompletionSource<TryResult<Place>>();  //ошибка, если нет строки;

            var placePicked = PlacePicker.GetPlace(this, data);

            var place = new Place(placePicked?.NameFormatted?.ToString(), placePicked.LatLng.Latitude, placePicked.LatLng.Longitude);

            ((MainActivity)CrossCurrentActivity.Current.Activity).TaskCompletionSource.TrySetResult(TryResult <Place> .Succeed(place));
        }
Exemplo n.º 5
0
 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     if (requestCode == REQUEST_PLACE_PICKER)
     {
         if (resultCode == Result.Ok)
         {
             IPlace place = PlacePicker.GetPlace(this, data);
             SetMarker(place.LatLng, place.NameFormatted.ToString());
         }
     }
 }
Exemplo n.º 6
0
        private void GetPlaceFromPicker(Intent data)
        {
            var placePicked = PlacePicker.GetPlace(this, data);
            var pickBounds  = placePicked.LatLng;

            picked = new LatLng(pickBounds.Latitude, pickBounds.Longitude);

            //LatLngBounds bounds = PlacePicker.GetLatLngBounds(data);
            _placeName.Text       = placePicked?.NameFormatted.ToString();
            _placeSecondName.Text = placePicked?.AddressFormatted.ToString();
        }
        /// <summary>
        /// Displays Place Picker UI.
        /// </summary>
        /// <param name="bounds"></param>
        /// <returns></returns>
        public Task <Places> Display(Abstractions.CoordinateBounds bounds = null)
        {
            currentRequest = GetRequestId();
            var ntcs = new TaskCompletionSource <Places>(currentRequest);

            if (Interlocked.CompareExchange(ref this.completionSource, ntcs, null) != null)
            {
                throw new InvalidOperationException("Only one operation can be active at a time");
            }
            Google.Maps.CoordinateBounds iosBound;
            PlacePickerConfig            config;

            if (bounds != null)
            {
                var northEast = new CLLocationCoordinate2D(bounds.Northeast.Latitude, bounds.Northeast.Longitude);
                var southwest = new CLLocationCoordinate2D(bounds.Southwest.Latitude, bounds.Southwest.Longitude);
                iosBound = new Google.Maps.CoordinateBounds(northEast, southwest);
                config   = new PlacePickerConfig(iosBound);
            }
            else
            {
                config = new PlacePickerConfig(null);
            }
            picker = new PlacePicker(config);
            picker.PickPlaceWithCallback(PlacePickedCallBack);
            EventHandler <PlacePickedEventArgs> handler = null;

            handler = (s, e) =>
            {
                var tcs = Interlocked.Exchange(ref this.completionSource, null);
                PlacePicked -= handler;

                if (e.RequestId != currentRequest)
                {
                    return;
                }
                if (e.IsCanceled)
                {
                    tcs.SetResult(null);
                }
                else if (e.Error != null)
                {
                    tcs.SetException(e.Error);
                }
                else
                {
                    tcs.SetResult(e.Places);
                }
            };
            PlacePicked += handler;
            return(completionSource.Task);
        }
Exemplo n.º 8
0
 public void OnShowPlacePicker()
 {
     PlacePicker.ShowPlacePicker(place =>
     {
         placeText.text = place.ToString();
     },
                                 error =>
     {
         var message    = "Picking place failed, message: " + error;
         placeText.text = message;
         Debug.Log(message);
     });
 }
Exemplo n.º 9
0
 protected void onActivityResult(int requestCode, Result resultCode, Intent data)
 {
     if (requestCode == PLACE_PICKER_REQUEST)
     {
         if (resultCode == Result.Ok)
         {
             IPlace place    = PlacePicker.GetPlace(this, data);
             String toastMsg = String.Format("Place: %s", place.NameFormatted);
             Toast.MakeText(this, toastMsg, ToastLength.Long).Show();
             //SetMarker(place.LatLng);
             data.PutExtra("lat", place.LatLng.Latitude);
             data.PutExtra("lon", place.LatLng.Longitude);
         }
     }
 }
Exemplo n.º 10
0
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            if (requestCode == PLACE_PICKER_ID && resultCode == Result.Ok)
            {
                var placePicked = PlacePicker.GetPlace(data, this);
                address          = placePicked.AddressFormatted.ToString();
                addressView.Text = address;
                ISharedPreferencesEditor editor = mPreferences.Edit();
                editor.PutString("address", address);
                editor.Commit();

                loadRepData();
                loadElectionData();
            }
            base.OnActivityResult(requestCode, resultCode, data);
        }
Exemplo n.º 11
0
 /// <summary>
 /// OnActivity Result
 /// </summary>
 /// <param name="requestCode"></param>
 /// <param name="resultCode"></param>
 /// <param name="data"></param>
 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     base.OnActivityResult(requestCode, resultCode, data);
     if (requestCode != REQUEST_PLACE_PICKER)
     {
         return;
     }
     if (resultCode == Result.Ok)
     {
         var         place       = PlacePicker.GetPlace(this, data);
         var         name        = place.NameFormatted.ToString();
         var         placeId     = place.Id;
         var         coordinate  = place.LatLng;
         Coordinates coordinates = null;
         if (place.LatLng?.Latitude != null && place.LatLng?.Longitude != null)
         {
             coordinates = new Coordinates(coordinate.Latitude, coordinate.Longitude);
         }
         var phone               = place.PhoneNumberFormatted?.ToString();
         var address             = place.AddressFormatted?.ToString();
         var attribution         = place.AttributionsFormatted?.ToString();
         var weburi              = place.WebsiteUri?.ToString();
         var priceLevel          = place.PriceLevel;
         var rating              = place.Rating;
         var swlatitude          = place.Viewport?.Southwest.Latitude;
         var swlongitude         = place.Viewport?.Southwest.Longitude;
         var nelatitude          = place.Viewport?.Northeast.Latitude;
         var nelongitude         = place.Viewport?.Northeast.Longitude;
         CoordinateBounds bounds = null;
         if (swlatitude != null && swlongitude != null && nelatitude != null && nelongitude != null)
         {
             bounds = new CoordinateBounds(new Coordinates(swlatitude.Value, swlongitude.Value), new Coordinates(nelatitude.Value, nelongitude.Value));
         }
         Places places = new Places(name, placeId, coordinates, phone, address, attribution, weburi, priceLevel, rating, bounds);
         OnPlaceSelected(new PlacePickedEventArgs(this.id, false, places));
         Finish();
         return;
     }
     else
     {
         OnPlaceSelected(new PlacePickedEventArgs(this.id, true));
         Finish();
         return;
     }
 }
Exemplo n.º 12
0
        void GetPlaceFromPicker(Intent data)
        {
            TextView placePickedAddress = FindViewById <TextView>(Resource.Id.textViewPickAPlaceAddress);
            TextView placePickedName    = FindViewById <TextView>(Resource.Id.textViewPickAPlaceName);

            _placePickedMessage = FindViewById <Android.Support.Design.Widget.TextInputEditText>(Resource.Id.textInputEditTextInvitationMessage);

            var placePicked = PlacePicker.GetPlace(this, data);

            if (placePicked != null)
            {
                placePickedName.Text    = placePicked.NameFormatted.ToString();
                placePickedAddress.Text = placePicked.AddressFormatted.ToString();
                _message = "Hi, let's meet at" + placePicked.NameFormatted + " , "
                           + placePicked.AddressFormatted.ToString()
                           + ". Location calculated and message generated using Meet.";
            }

            _placePickedMessage.Text = _message;
        }
Exemplo n.º 13
0
        private async void GetPhotos(Intent data)
        {
            var            placePicked = PlacePicker.GetPlace(this, data);
            var            gallery     = FindViewById <LinearLayout>(Resource.Id.linearGallery);
            LayoutInflater inflanter   = LayoutInflater.From(this);
            //_Image = FindViewById<ImageView>(Resource.Id.ImageGoogle);
            string placeId = placePicked.Id;

            if (gallery.ChildCount > 0)
            {
                gallery.RemoveAllViews();
            }

            int count = 0;

            using (var photoMetadataResponse = await mGeoDataClient.GetPlacePhotosAsync(placeId))
                using (var photoMetadataBuffer = photoMetadataResponse.PhotoMetadata)
                {
                    foreach (var item in photoMetadataBuffer)
                    {
                        using (var photoResponse = await mGeoDataClient.GetPhotoAsync(item))
                        {
                            View view = inflanter.Inflate(Resource.Layout.ImageItem, gallery, false);
                            image = view.FindViewById <ImageView>(Resource.Id.ImageGoogle);
                            var bitmap = photoResponse.Bitmap;

                            string imgaBitmapToString = ConvertBitmapToString(bitmap);


                            _imagesStorage.Add(imgaBitmapToString);


                            image.SetImageBitmap(bitmap);
                            gallery.AddView(view);
                            count++;
                        }
                    }
                }
        }
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (requestCode == RequestPickAvatar && resultCode == Result.Ok)
            {
                var progressDialog = this.CreateDialog(GetString(Resource.String.upload_a_photo),
                                                       GetString(Resource.String.wait));
                progressDialog.Show();

                this.DoRequest(CloudinaryController.UploadImage(this, data.Data, $"Images/{Guid.NewGuid()}", 256),
                               () => progressDialog.Dismiss());

                imgEvent.SetImageURI(data.Data);
            }

            if (requestCode != PlacePickerRequset || resultCode != Result.Ok)
            {
                return;
            }
            place = PlacePicker.GetPlace(this, data);
            edtChooseLocation.Text = place.AddressFormatted.ToString();
        }