private void TwitterRequest_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message);
            }
            else
            {
                this.FeatureSets.Remove(twitterSet);
                TwitterResult twResult = TwitterResult.Deserialize(e.Result);
                twitterSet = new GeoFeatureCollection("title,photoUrl,authorUri,content", "Title,Photo,Author,Content", "title", "Tweets");

                if (twResult != null)
                {
                    foreach (TweetItem item in twResult.items)
                    {
                        Graphic graphic = new Graphic();
                        graphic.Geometry = (new MapPoint(item.geoLocation.x, item.geoLocation.y, new SpatialReference(4326))).GeographicToWebMercator();
                        graphic.Attributes.Add("title", item.author.authorName);
                        graphic.Attributes.Add("photoUrl", item.authorLinks[1].linkUrl);
                        graphic.Attributes.Add("authorUri", item.author.authorUri);
                        graphic.Attributes.Add("content", item.content);
                        graphic.Symbol = twitterSymbol;
                        graphic.MapTip = twitterTipTemplate;
                        graphicsLayer.Graphics.Add(graphic);
                        twitterSet.Add(graphic);
                    }

                    this.FeatureSets.Add(twitterSet);
                    this.ToggleWidgetContent(1);
                }
            }

            this.IsBusy = false;
        }
        private void FlickrRequest_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message);
            }
            else
            {
                this.FeatureSets.Remove(flickrsSet);
                FlickrResult frResult = FlickrResult.Deserialize(e.Result);
                flickrsSet = new GeoFeatureCollection("title,photoUrl,ownerName,dateTaken", "Title,Photo,Owner,Date", "title", "Flickr");

                if (frResult != null && frResult.photoPage != null && frResult.photoPage.photos != null)
                {
                    foreach (FlickrPhoto item in frResult.photoPage.photos)
                    {
                        Graphic graphic = new Graphic();
                        graphic.Geometry = (new MapPoint(item.longitude, item.latitude, new SpatialReference(4326))).GeographicToWebMercator();
                        graphic.Attributes.Add("title", item.title);
                        graphic.Attributes.Add("photoUrl", item.photoUrl);
                        graphic.Attributes.Add("ownerName", item.ownerName);
                        graphic.Attributes.Add("dateTaken", item.dateTaken);
                        graphic.Symbol = flickrSymbol;
                        graphic.MapTip = flickrTipTemplate;
                        graphicsLayer.Graphics.Add(graphic);
                        flickrsSet.Add(graphic);
                    }

                    this.FeatureSets.Add(flickrsSet);
                    this.ToggleWidgetContent(1);
                }
            }

            this.IsBusy = false;
        }
Пример #3
0
        private void Query_ResultReady(object sender, QueryResultEventArgs args)
        {
            this.ClearGraphics(2); // Toggle to Results Panel

            if (args.Results != null && args.Results.Features.Count > 0)
            {
                isFirstLoad = true; // Suppress filter results by map extent or pan map
                QueryResultMessage.Visibility = Visibility.Collapsed;

                FeatureSet           fset    = args.Results;
                Symbol               symbol  = ChooseSymbol(fset.GeometryType.ToString(), false);
                GeoFeatureCollection dataset = new GeoFeatureCollection(args.QueryLayer.OutputFields, args.QueryLayer.OutputLabels, fset.DisplayFieldName, args.QueryLayer.Title);

                foreach (Graphic feature in fset.Features)
                {
                    feature.Symbol = symbol;
                    feature.Geometry.SpatialReference = fset.SpatialReference;
                    this.GraphicsLayer.Graphics.Add(feature);
                    dataset.Add(feature);
                }

                this.FeatureSets.Add(dataset);
                this.GraphicsTipTemplate = args.QueryLayer.MapTipTemplate;
                this.MapControl.ZoomTo(GeometryTool.ExpandGeometryExtent(this.GraphicsLayer.FullExtent, 0.25));
            }
            else
            {
                QueryResultMessage.Visibility = Visibility.Visible;
                QueryResultMessage.Text       = string.Format("Sorry! {0}", (string.IsNullOrEmpty(args.ErrorMsg)) ? "No features are found." : args.ErrorMsg);
            }

            this.IsBusy = false;
        }
        private void YouTubeRequest_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message);
            }
            else
            {
                this.FeatureSets.Remove(youtubeSet);
                YouTubeResult ytResult = YouTubeResult.Deserialize(e.Result);
                youtubeSet = new GeoFeatureCollection("title,thumbnail,description,publishDate,playerUrl", "Title,Thumbnail,Description,Publish Date,Player Url", "title", "YouTube");

                if (ytResult != null)
                {
                    foreach (YouTubeItem ytItem in ytResult.items)
                    {
                        Graphic graphic = new Graphic();
                        graphic.Geometry             = (new MapPoint(ytResult.items[0].geometry.rssPoint.x, ytResult.items[0].geometry.rssPoint.y, new SpatialReference(4326))).GeographicToWebMercator();
                        graphic.MouseLeftButtonDown += new MouseButtonEventHandler(YouTube_MouseLeftButtonDown);
                        graphic.Attributes.Add("title", ytItem.media.title);
                        graphic.Attributes.Add("thumbnail", ytItem.media.thumbnail[1].url); //hddefault.jpg (480 x 360)
                        graphic.Attributes.Add("aspectRatio", ytItem.media.aspectRatio);
                        graphic.Attributes.Add("description", ytItem.media.description);
                        graphic.Attributes.Add("publishDate", ytItem.media.publishDate);
                        graphic.Attributes.Add("contentUrl", ytItem.media.content[0].source);
                        graphic.Attributes.Add("playerUrl", "http://www.youtube.com/watch?v=" + ytItem.media.videoID);
                        graphic.Symbol = youtubeSymbol;
                        graphic.MapTip = youtubeTipTemplate;
                        graphicsLayer.Graphics.Add(graphic);
                        youtubeSet.Add(graphic);
                    }

                    this.FeatureSets.Add(youtubeSet);
                    this.ToggleWidgetContent(1);
                }
            }

            this.IsBusy = false;
        }
Пример #5
0
        private void AddGeoRSSGraphics(List <GeoRSSItem> rssItems)
        {
            if (this.GraphicsLayer == null)
            {
                MessageBox.Show("GraphicsLayer for this widget is not created. Please set property HasGraphics 'true'."); return;
            }

            GeoFeatureCollection dataset = new GeoFeatureCollection("Title", "GeoRSS");

            foreach (GeoRSSItem rssItem in rssItems)
            {
                Graphic graphic = new Graphic();
                graphic.Geometry = rssItem.Geometry;
                graphic.Symbol   = ChooseSymbol(rssItem.Geometry);
                graphic.Attributes.Add("Title", rssItem.Title);
                graphic.Attributes.Add("Description", rssItem.Description);
                graphic.Attributes.Add("PubDate", rssItem.pubDate);
                graphic.Attributes.Add("Link", rssItem.Link);
                this.GraphicsLayer.Graphics.Add(graphic);
                dataset.Add(graphic);
            }

            this.FeatureSets.Add(dataset); // Make it available for the Print Widget
        }
Пример #6
0
        private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs e)
        {
            string mapName = (string)e.UserState;
            string preName = "^?^";

            GeoFeatureCollection features = null;

            foreach (IdentifyResult result in e.IdentifyResults)
            {
                if (result.LayerName != preName)
                {
                    if (features != null)
                    {
                        this.FeatureSets.Add(features);
                    }

                    AddToGraphicsLayer(result.Feature, (string)result.Value, result.DisplayFieldName, result.LayerName);
                    features = new GeoFeatureCollection(result.DisplayFieldName, result.LayerName, mapName);
                    features.Add(result.Feature);
                    preName = result.LayerName;
                }
                else if (features != null)
                {
                    AddToGraphicsLayer(result.Feature, (string)result.Value, result.DisplayFieldName, result.LayerName);
                    features.Add(result.Feature);
                }
            }

            // Add the last layer results
            if (features != null)
            {
                this.FeatureSets.Add(features);
            }

            this.IsBusy = false;
        }