コード例 #1
0
ファイル: MapView.xaml.cs プロジェクト: hansmei/PhotoVis
        private void ShowAllData()
        {
            PushpinLayer.Children.Clear();

            if (_generatingData)
            {
                StatusTbx.Text += "Database is still loading.\r\n";
                return;
            }

            if (App.MapVM.FilterdImageLocations.Count == 0)
            {
                StatusTbx.Text += "No database data found.\r\n";
                return;
            }

            foreach (ImageAtLocation img in App.MapVM.FilterdImageLocations)
            {
                ColoredPushpin p = _options.RenderEntity(img);
                string         strokeColor;
                p.FillColor   = App.MapVM.GetPushpinColors(img, out strokeColor);
                p.StrokeColor = strokeColor;
                PushpinLayer.Children.Add(p);
            }

            //StatusTbx.Text += "All data displayed without clustering.\r\n";
        }
コード例 #2
0
        public override ColoredPushpin RenderCluster(ClusteredPoint cluster)
        {
            var p = new ColoredPushpin();

            MapLayer.SetPosition(p, cluster.Location);
            p.Content = "+";
            p.Tag     = cluster;
            p.ToolTip = new ToolTip()
            {
                Content = string.Format("{0} Clustered Entities", cluster.EntityIds.Count)
            };

            //ControlTemplate myTemplate = (ControlTemplate)Application.Current.FindResource("PushpinColorTemplate");
            //p.Template = myTemplate;
            //p.ApplyTemplate();

            return(p);
        }
コード例 #3
0
        public override ColoredPushpin RenderEntity(Entity entity)
        {
            var p = new ColoredPushpin();

            MapLayer.SetPosition(p, entity.Location);
            p.Tag     = entity;
            p.ToolTip = new ToolTip()
            {
                Content = (entity as ImageAtLocation).Title
            };

            ControlTemplate myTemplate = (ControlTemplate)Application.Current.FindResource("PushpinColorTemplate");

            p.Template = myTemplate;
            p.ApplyTemplate();

            return(p);
        }
コード例 #4
0
ファイル: MapView.xaml.cs プロジェクト: hansmei/PhotoVis
        private void ShowImage(int imageIndex)
        {
            // Check for potential error
            if (this.selectedImages.Count <= imageIndex || imageIndex < 0)
            {
                this.ReturnToMap();
                return;
            }

            ImageAtLocation image = this.selectedImages[imageIndex];

            if (this.preloadedImages != null && this.preloadedImages[imageIndex] != null)
            {
                currentImage.Source = this.preloadedImages[imageIndex];
            }
            else
            {
                BitmapImage b1 = new BitmapImage();
                b1.BeginInit();
                b1.CacheOption       = BitmapCacheOption.Default;
                b1.UriSource         = new Uri(image.ImagePath, UriKind.RelativeOrAbsolute);
                b1.DecodePixelHeight = 800;
                b1.EndInit();
                b1.Freeze();
                currentImage.Source = b1;

                if (this.preloadedImages != null && imageIndex == 0)
                {
                    this.preloadedImages[0] = b1;
                }
            }

            this.imageCounter.Text  = (imageIndex + 1) + "/" + this.selectedImages.Count;
            this.ImageFileName.Text = System.IO.Path.GetFileName(image.ImagePath);
            this.ImageSaveDate.Text = "";
            this.ImageTaken.Text    = image.TimeImageTaken.ToString(App.RegionalCulture);
            this.Creator.Text       = image.Creator.ToString();

            // Zoom the inner map
            this.InnerMap.Children.Clear();
            int     i         = 0;
            Pushpin activePin = null;

            foreach (ImageAtLocation img in this.selectedImages)
            {
                ColoredPushpin pin = _options.RenderEntity(img);
                string         strokeColor;
                pin.FillColor   = App.MapVM.GetPushpinColors(img, out strokeColor);
                pin.StrokeColor = strokeColor;

                pin.Tag = i + 1;
                if (i == imageIndex)
                {
                    ControlTemplate myTemplate = (ControlTemplate)FindResource("PushpinControlTemplate");
                    pin.Template = myTemplate;
                    pin.ApplyTemplate();
                    activePin = pin;
                }
                else
                {
                    this.InnerMap.Children.Add(pin);
                }
                i++;
            }
            // Make sure the active pin are added last
            this.InnerMap.Children.Add(activePin);

            if (image.HasLocation)
            {
                // Set the URL for the google street view
                List <Location> locations = this.selectedImages.Where(s => s.Location != null).Select(s => s.Location).ToList();
                LocationRect    bounds    = new LocationRect(locations);

                double height = Measure(bounds.North, bounds.East, bounds.South, bounds.West);
                //int zoom = GetZoomLevel(height, bounds.Center.Latitude, this.webView.ActualHeight, this.webView.ActualWidth);
                //if (zoom > 19)
                //    zoom = 19;
                //if (zoom < 0)
                //    zoom = 19;
                //if (zoom < 4)
                //    zoom = 4;

                //this.StreetViewContainer.NavigationCompleted += StreetViewContainer_NavigationCompleted;
                string googleStreetViewString =
                    string.Format(@"https://www.google.com/maps/@?api=1&map_action=pano&viewpoint={0},{1}&heading=-45&pitch=0&fov=80",
                                  //string.Format(@"https://www.google.com/maps/@{0},{1},{2}z",
                                  image.Location.Latitude.ToString(CultureInfo.InvariantCulture), image.Location.Longitude.ToString(CultureInfo.InvariantCulture));
                //this.StreetViewContainer.Navigate(new Uri(googleStreetViewString));
                this.MyBrowserControl.URL = googleStreetViewString;
            }
        }