public MainMapView() { this.InitializeComponent(); this._viewModel = ViewModelLocator.MainMapViewModelStatic; this.mainMap.CredentialsProvider = new ApplicationIdCredentialsProvider(ApiKeys.BingMapsKey); this.mainMap.SetView(new GeoCoordinate(39.450, -98.908), 3.3); // The following is simply to have the timeConditionPicker text aligned. var temp = this._viewModel.TimeType; this._viewModel.TimeType = TimeCondition.LastArrivalTime; this._viewModel.TimeType = temp; this.RegisterNotifications(); this.RegisterForNotification( "SelectedItem", this.directionsStepView, (d, e) => { if (this._viewModel.SelectedTransitTrip != null) { this._viewModel.CenterMapGeoSet = true; this.mainMap.SetView(this._viewModel.SelectedTransitTrip.ItinerarySteps[this.directionsStepView.SelectedItem == -1 ? 0 : directionsStepView.SelectedItem].GeoCoordinate, Globals.LocateMeZoomLevel); this.SetUIVisibility(UIViewState.ItineraryView); } }); // Must be able to quit application with BackKey press when opening the app. // So show the map view always when starting up. this.SetUIVisibility(UIViewState.MapViewOnly); // Additional logic for application start up view. if (this._viewModel.SelectedTransitTrip != null) { this.mainMap.SetView(this._viewModel.SelectedTransitTrip.MapView); // set zoom a little lower so endpoints don't underlap overlays this.mainMap.ZoomLevel = this.mainMap.TargetZoomLevel - 0.4; } else if (!this._viewModel.CenterMapGeoSet && ViewModelLocator.SettingsViewModelStatic.UseLocationSetting && this._viewModel.UserGeoCoordinate != null) { this.mainMap.SetView(this._viewModel.UserGeoCoordinate, Globals.LocateMeZoomLevel); } LittleWatson.CheckForPreviousException(); }
public static void CreateMainMapViewModel() { if (_mainMapViewModel == null) { _mainMapViewModel = new MainMapViewModel(); } }
public static void ClearMainMapViewModel() { _mainMapViewModel.Cleanup(); _mainMapViewModel = null; }