private void OnBtnLocalizeClicked(MapPage mapPage) { var myLocation = GetMyLocation(); if (myLocation == null) { Logger.Log("Brak sygna³u GPS."); MessagingCenter.Send(_myMap, "DisplayAlert", new AlertMessage("B³¹d", "Brak sygna³u GPS.")); return; } var myLatLng = new Android.Gms.Maps.Model.LatLng(myLocation.Latitude, myLocation.Longitude); // Create new starting marker. if (_startMarker == null) { var marker = new MarkerOptions(); marker.SetPosition(myLatLng); marker.SetTitle("Od"); marker.Draggable(false); // TODO: Custom start icon. _startMarker = _map.AddMarker(marker); _startMarker.ShowInfoWindow(); } // Move existing marker. else { _startMarker.Position = myLatLng; } _map.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(myLatLng, DefaultZoom)); // TODO: Display nearest stations. var nearestStations = App.Database.GetNearestStations(myLatLng.Latitude, myLatLng.Longitude, 5); for (var i = 0; i < nearestStations.Length; i++) { var station = nearestStations[i]; var marker = new MarkerOptions(); var latLng = new Android.Gms.Maps.Model.LatLng(station.latitude, station.longitude); marker.SetPosition(latLng); marker.SetTitle(string.Format("{0}. {1} - {2}", station.postId, station.postName, station.street)); marker.Draggable(false); marker.SetSnippet("Wiêcej..."); // TODO: Custom stations's icon. var mapMarker = _map.AddMarker(marker); var stationMarker = new StationMarker(station, mapMarker); _nearestMarkers.Add(stationMarker); } }
private void OnBtnFindRouteClicked(MapPage mapPage) { if (Options.TestMode) { var args = new double[] { 0, 0, 0, 0 }; MessagingCenter.Send(_myMap, "SendServerRequest", args); } else { if (_startMarker == null) return; if (_destinationMarker == null) return; var args = new double[] { _startMarker.Position.Latitude, _startMarker.Position.Longitude, _destinationMarker.Position.Latitude, _destinationMarker.Position.Longitude }; MessagingCenter.Send(_myMap, "SendServerRequest", args); } }