public MapPickerPage(LocationPickerType pickerType, GooglePlace selectedAddress = null) { InitializeComponent(); SelectedAddress = selectedAddress; PickerType = pickerType; #if __IOS__ if (App.Locator.DeviceService.IsIphoneX() == true) { TitleLabel.TranslationY = 35; BackButton.TranslationY = 10; } else { TitleLabel.TranslationY = 24; } #elif __ANDROID__ TitleLabel.TranslationY = 5; BackButton.TranslationY = -18; BackButton.TranslationX = -30; #endif SelectButton.Opacity = 0; MapView.UiSettings.ZoomControlsEnabled = false; MapView.MyLocationEnabled = true; MapView.CameraIdled += (sender, e) => { if (SelectButton.Opacity > 0) { LoadAddress(MapView.CameraPosition.Target.Latitude, MapView.CameraPosition.Target.Longitude); } }; if (SelectedAddress != null) { SelectButton.Opacity = 1; MapView.InitialCameraUpdate = CameraUpdateFactory.NewPositionZoom(new Position(SelectedAddress.Latitude, SelectedAddress.Longitude), 20d); LoadAddress(SelectedAddress.Latitude, SelectedAddress.Longitude); } else if (!App.Locator.LocationHelper.lat.Equals(0.0)) { MapView.InitialCameraUpdate = CameraUpdateFactory.NewPositionZoom(new Position(App.Locator.LocationHelper.lat, App.Locator.LocationHelper.lng), 20d); } if (PickerType == LocationPickerType.To) { TitleLabel.Text = AppResources.SelectToLocation; } else if (PickerType == LocationPickerType.From) { TitleLabel.Text = AppResources.SelectFromLocation; } }
private async void SetLocationImage(LocationPickerType pickerType, double lat, double lng) { var size = 300; #if __ANDROID__ size = 340; #endif var mapHelper = new MapHelper(); var mapImage = await mapHelper.GetStaticMap(lat, lng, 18, size, size); MemoryStream stream = null; if (mapImage != null) { stream = new MemoryStream(mapImage); } if (pickerType == LocationPickerType.From) { if (stream != null) { FromLocationImage.Source = ImageSource.FromStream(() => stream); } else { FromLocationImage.Source = "map_black_icon.png"; } } else if (pickerType == LocationPickerType.To) { if (stream != null) { ToLocationImage.Source = ImageSource.FromStream(() => stream); } else { ToLocationImage.Source = "map_black_icon.png"; } } }
public LocationPickerPage(LocationPickerType pickerType, GooglePlace selectedAddress = null) { InitializeComponent(); SelectedAddress = selectedAddress; PickerType = pickerType; #if __IOS__ if (App.Locator.DeviceService.IsIphoneX() == true) { TitleLabel.TranslationY = 35; BackButton.TranslationY = 10; } else { TitleLabel.TranslationY = 24; } #elif __ANDROID__ TitleLabel.TranslationY = 5; BackButton.TranslationY = -18; BackButton.TranslationX = -30; #endif if (PickerType == LocationPickerType.To) { TitleLabel.Text = AppResources.SelectToLocation; SearchField.Placeholder = AppResources.LocationPickerTypeTo; } else if (PickerType == LocationPickerType.From) { TitleLabel.Text = AppResources.SelectFromLocation; SearchField.Placeholder = AppResources.LocationPickerTypeFrom; } PlacesRetrieved(new AutoCompleteResult()); if (SelectedAddress != null) { SearchField.Text = SelectedAddress.Address; } }