예제 #1
0
        private async void DetailMap_MapClicked(object sender, Xamarin.Forms.Maps.MapClickedEventArgs e)
        {
            Latitude  = e.Position.Latitude;
            Longitude = e.Position.Longitude;

            string GetAddress = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + Latitude.ToString() + "," + Longitude + "&key=" + api_key + "&language=th";

            using (HttpResponseMessage response = await _client.GetAsync(GetAddress))
            {
                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    using (HttpContent contents = response.Content)
                    {
                        string mycontent = await contents.ReadAsStringAsync();

                        JObject maps_details = JObject.Parse(mycontent);
                        location_details = maps_details["results"][0]["formatted_address"].ToString();
                    }
                }
                else
                {
                    await DisplayAlert("Error", "เกิดข้อผิดพลาดกรุณาลองใหม่", "OK");
                }
            }

            var pin = new Pin
            {
                Position = new Position(e.Position.Latitude, e.Position.Longitude),
                Label    = "สถานที่ทำงาน",
                Address  = location_details
            };

            DetailMap.Pins.Clear();
            DetailMap.Pins.Add(pin);
        }
예제 #2
0
        private void map_MapClicked(object sender, Xamarin.Forms.Maps.MapClickedEventArgs e)
        {
            map.Pins.Clear();
            map.Pins.Add(new Pin()
            {
                Position = e.Position,
                Label    = AppResources.SelectedPosition
            });

            viewModel.Activity.Position = e.Position;
        }
 private void map_MapClicked(object sender, Xamarin.Forms.Maps.MapClickedEventArgs e)
 {
     map.Pins.Clear();
     StreetLoc = new Pin
     {
         Position = e.Position,
         Label    = "Picture Location",
         Address  = "",
         Type     = PinType.SearchResult
     };
     map.Pins.Add(StreetLoc);
 }
예제 #4
0
 private void OnMapCliked(object sender, Xamarin.Forms.Maps.MapClickedEventArgs e)
 {
     if (IsDisplay)
     {
         frameSearch.TranslateTo(0, -200, 1000);
         Info.TranslateTo(0, 200, 1000);
         IsDisplay = false;
     }
     else
     {
         frameSearch.TranslateTo(0, 0, 1000);
         Info.TranslateTo(0, 0, 1000);
         IsDisplay = true;
     }
 }
예제 #5
0
        async private void BindableMap_MapClicked(object sender, Xamarin.Forms.Maps.MapClickedEventArgs e)
        {
            try
            {
                var _setting = DependencyService.Get <IAppSettings>();
                if (_setting.IsLogin && _setting.IsOnline)
                {
                    vm.MyPosition = new Position(e.Position.Latitude, e.Position.Longitude);
                    vm.IsBusy     = true;
                    var placemarks = await Geocoding.GetPlacemarksAsync(e.Position.Latitude, e.Position.Longitude);

                    var    placemark      = placemarks?.FirstOrDefault();
                    string Locationstring = "";
                    if (placemark != null)
                    {
                        Locationstring = $"{placemark.SubAdminArea}  {placemark.AdminArea}, { placemark.SubLocality} {placemark.Locality} ,  {placemark.PostalCode} {placemark.CountryName}";
                    }
                    vm.PinCollection = new System.Collections.ObjectModel.ObservableCollection <Pin>();
                    vm.PinCollection.Add(new Pin()
                    {
                        Position = vm.MyPosition, Type = PinType.Generic, Label = $"Slaughter House Location"
                    });


                    vm.IsBusy = false;
                }
                else
                {
                    vm.IsEmpty         = true;
                    vm.EmptyStateTitle = AppAlertMessage.NoInternetConnections;
                }
            }
            catch (Exception ex)
            {
                vm.IsBusy = false;
            }
        }
예제 #6
0
 private async void map_MapClicked(object sender, Xamarin.Forms.Maps.MapClickedEventArgs e)
 {
     System.Diagnostics.Debug.WriteLine($"MapClick: {e.Position.Latitude}, {e.Position.Longitude}");
     await DisplayAlert("Información", $"MapClick: {e.Position.Latitude}, {e.Position.Longitude}", "Aceptar");
 }
예제 #7
0
 private async void OnShowRoute(object sender, Xamarin.Forms.Maps.MapClickedEventArgs e)
 {
     //var result = await DirectionsApi.GetRoute()
 }