public GasStationLocatorPage() { System.Diagnostics.Debug.WriteLine("Initialize component"); InitializeComponent(); getUserPosition().ContinueWith((t) => { System.Diagnostics.Debug.WriteLine("Task call back " + t.Result.Latitude + ", " + t.Result.Longitude); Device.BeginInvokeOnMainThread(() => { lastGPSPosition = t.Result; setMapUserPosition(t.Result); }); fetchNearGasStations(t.Result, searchRadius).ContinueWith((arg) => { System.Diagnostics.Debug.WriteLine("fetchNearGasStations result " + arg.Result.results.Count); Device.BeginInvokeOnMainThread(() => { for (int i = 0; i < arg.Result.results.Count; i++) { PlaceGasStation gasStation = (PlaceGasStation)arg.Result.results[i]; var lat = gasStation.geometry.location.lat; var lng = gasStation.geometry.location.lng; addPin(lat, lng, gasStation.name, gasStation.vicinity); } }); }); }); }
public void OnPickerSelectedIndexChanged(object sender, EventArgs args) { System.Diagnostics.Debug.WriteLine("Picker selected"); Picker picker = (Picker)sender; int selectedIndex = picker.SelectedIndex; if (selectedIndex == -1) { return; } searchRadius = picker.Items[selectedIndex]; fetchNearGasStations(lastGPSPosition, searchRadius).ContinueWith((arg) => { System.Diagnostics.Debug.WriteLine("fetchNearGasStations result " + arg.Result.results.Count); Device.BeginInvokeOnMainThread(() => { for (int i = 0; i < arg.Result.results.Count; i++) { PlaceGasStation gasStation = (PlaceGasStation)arg.Result.results[i]; var lat = gasStation.geometry.location.lat; var lng = gasStation.geometry.location.lng; addPin(lat, lng, gasStation.name, gasStation.vicinity); } }); }); }