示例#1
0
        async void GetNearestStops()
        {
            try {
                StoppingPlaces data = null;
                if (!_debugLocatoin)
                {
                    data = await _mapViewModel.GetNearestStops(_currentLocation.Latitude, _currentLocation.Longitude);
                }
                else
                {
                    data = await _mapViewModel.GetNearestStops(57.724215, 11.970159);
                }

                if (data.GetList().Count > 0)
                {
                    /*
                     * Zoom in on first result
                     */
                    _googleMap.Clear();
                    var stopList  = data.GetList();
                    var firstStop = stopList[0];
                    PositionCamera(_currentLocation);


                    _googleMap.InfoWindowClick += (sender, e) => {
                        var stopPlace = stopList.Find(x => x.Name == e.Marker.Title);
                        MapBridge.Instance.FireStoppingPlaceSelcted(stopPlace);
                    };



                    /*
                     * Create markers
                     */
                    foreach (StoppingPlace stop in stopList)
                    {
                        _googleMap.AddMarker(new MarkerOptions()
                                             .SetPosition(new LatLng(stop.Lat, stop.Lon))
                                             .SetTitle(stop.Name)
                                             .SetIcon(BitmapDescriptorFactory.FromResource(stops.Resource.Drawable.marker)));
                    }
                }
            }
            catch (Exception) {
                Snackbar.Make(_snackBarView, "Gick inte att hämta hållplatser", Snackbar.LengthIndefinite)
                .SetAction("Fösök igen", (view) => {
                    GetNearestStops();
                }).Show();
            }
        }
 public bool HasLatestCLickeStop()
 {
     return(latestChociedStop.GetList().Count == 1);
 }