c# - getting information about which push pin was clicked -
I am creating a Windows Phone 8.1 app that reads a file (which has GPS points, in each point Latitude and longitude fields) for every point, it is because it is displayed with a little push pin icon on map control depending on the coordinated file of the above file. I want to click the pushpins and the final goal is to get the latitude and longitude of the point on which the user clicked and took the appropriate action on which one click has been made. How can I get this information? This is what I tried to do but it does not work:
Private async void Image_Tapped (Object Sender, Tapped Event ARG E) {var point = Sender Geopoint; MessageDialog msgbox = New MessageDialog ("Point Tape:" + point.Position.Latitude); Msgbox.ShowAsync (); }
This is my template:
& lt; Maps: Map Controller x: Name = "myMap" & gt; & Lt; Map: MapItem Control Item Surce = "{Binding}" & gt; & Lt; Map: MapItemsControl.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; Image Source = "Assets / Pushpin." "Taped" = "ImageGapped" width = "50" height = "50" Maps: Map control. Location = "{binding}" & gt; & Lt; / Image & gt; & Lt; / DataTemplate & gt; & Lt; / Map: MapItemsControl.ItemTemplate & gt; & Lt; / Map: MapItemsControl & gt; & Lt; / Map: MapControl & gt;
This is the file I read and display for pushpin (this shows them properly)
Protected async override zero-nav navigate To (NavigationEventEurvees E) {Geolocation Status = app.DataModel.GetCurrentPosition () Wait; Wait for the Marimata. Trisexviewsink (status coordinate page, 16d); & Lt; Geopoint & gt; List = new list & lt; Geopoint & gt; (); Bull exists; // If the JSON file exists, it is used to check = App.DataModel.FileExistsAsync () wait; If (exist == true) {// file and load point view in the App.DataModel.ReadFile (); Leading (application data modell.not different points in notes) {Geopoint geographical = new geopointment (new latitude = point.lititid, longitude = point.value}} list.Add (geo);}} MyMap.DataContext = List;}
In your Image_Tapped
handler, the sender variable Is not a geopoint
, this is a image
.but Geopoint
this image should be DataContext
.
var point = (as the sender image). Dat as Geopoint Acontext;
Comments
Post a Comment