public Map() { InitializeComponent(); InitializeControls(); this.currentPushpin = new ImagePushpin(null) { Location = DeviceLocationInfo.Current.CurrentCoordinates, }; }
private void DrawEntitiesOnMap() { this.mapLayer.Children.Clear(); var lat = 0.0; var lng = 0.0; if (this.showSingleEntity) { // show only selected entity var selectedEntity = CashMachineRepository.Current.GetById(new Guid(this.zoomToEntityId)); var entityPushpin = new ImagePushpin(selectedEntity); this.mapLayer.AddChild(entityPushpin.Image, entityPushpin.Location, PositionOrigin.Center); this.map.SetView(entityPushpin.Location, 18); lat = selectedEntity.Latitude; lng = selectedEntity.Longitude; } else { var list = GetEntityList(); if (list != null && list.Any()) { foreach (var entity in list) { var entityPushpin = new ImagePushpin(entity) { Image = { Tag = entity.Id } }; entityPushpin.Image.MouseLeftButtonUp += ImageOnMouseLeftButtonUp; this.mapLayer.AddChild(entityPushpin.Image, entityPushpin.Location, PositionOrigin.Center); if (!string.IsNullOrEmpty(this.zoomToEntityId)) { if (entity.Id.ToString().Equals(this.zoomToEntityId)) { this.map.SetView(entityPushpin.Location, 18); } } } var closet = list.First(); lat = closet.Latitude; lng = closet.Longitude; } } if (IsFirstLaunch) { CenterMap(); if (AppSettings.Instance.ZoomToClosestSetting) { this.map.SetView(new LocationRect(Math.Max(this.currentPushpin.Location.Latitude, lat), Math.Min(this.currentPushpin.Location.Longitude, lng), Math.Min(this.currentPushpin.Location.Latitude, lat), Math.Max(this.currentPushpin.Location.Longitude, lng))); } PhoneApplicationService.Current.State[IsFirstlaunchCackeKey] = false; } this.mapLayer.AddChild(this.currentPushpin.Pushpin, this.currentPushpin.Location, PositionOrigin.Center); this.loadingBar.Visibility = Visibility.Collapsed; }