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.
@Programmer You should read current Pin's info instead of using the property pins
's information. So modify your code like:
private void Pin_Clicked(object sender, EventArgs e) { Pin singlePin = sender as Pin; DisplayAlert($"{singlePin.Label}", $"{singlePin.Address}", "Ok"); }
Answers
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 ?
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
@Programmer You should read current Pin's info instead of using the property
pins
's information. So modify your code like:please me help to solve this problem https://stackoverflow.com/questions/55341249/how-to-make-custom-info-window-in-xamarin-maps
@LandLu How to send that information to next page?
update: nevermind I figured it out