Pass pins value to next page in xamarin forms

ProgrammerProgrammer Member ✭✭

Hello all.
I am using map in my app.i add some pins in the map . When i click on pin it display some info.Now i want to pass the values/info of pins to next page after clicking on pin tooltip. here is what i am trying.

Pin pins;
        protected async override void OnAppearing()
        {
            base.OnAppearing();
            // workerListVM.DisplayMap();
            var employeesDetail = await workerListVM.getdetail();
            foreach (var employees in employeesDetail)
            {
                try
                {
                    map1.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(employees.Latitude, employees.Longitude),Distance.FromMiles(.5)));
                    var position = new Position(employees.Latitude, employees.Longitude);

                     pins = new Pin()
                    {
                        Type = PinType.Place,
                        Position = position,
                        Label = employees.UserName,
                        Address = employees.City
                    };
                    map1.Pins.Add(pins);
                    pins.Clicked += Pins_Clicked;
                }
                catch (NullReferenceException) { }
                catch (Exception) { }
            }
        }

        private void Pins_Clicked(object sender, EventArgs e)
        {
            DisplayAlert($"{pins.Label}", $"{pins.Address}", "Ok");
        } 

but its not working.

Best Answer

Answers

  • AsurAsur USMember ✭✭✭

    Default behavior is pins.Click fires when you click the label that pops up when clicking the pin . So did you try clicking the marker/label as well ?

  • ProgrammerProgrammer Member ✭✭

    when i click the pin,a marker/label pops up and then when i click on marker/label it display alert .but problem is it always display the same values for each pin click.but i want to display only the values of the pin i click

Sign In or Register to comment.