Thursday, May 03, 2012

LocationServices for Windows Phone update: added Twitter

I’ve added Twitter as a new data layer library with a search criteria to SearchByRadius. Using this search will return all tweets with a valid geo location (either by the Geo attribute, or by a string parse of the Location attribute) within the set radius from the specified location (GeoCoordinate).

twitter

Usage example

        public MainViewModel()
        {
            this.twitterrservicelayer = new Service.Twitter.Reactive.ServiceLayer();
        }
        private ObservableCollection<GenericPivotItem> pivotItems;
        public ObservableCollection<GenericPivotItem> PivotItems { get { if (pivotItems == null) pivotItems = new ObservableCollection<GenericPivotItem>(); return pivotItems; } set { pivotItems = value; } }
        public Service.Twitter.Reactive.ServiceLayer twitterrservicelayer { get; private set; }

        private void WireTwitterPivotItem()
        {
            IsDataLoading = true;
            GenericPivotItem tweets = new GenericPivotItem() { Header = "tweets", Source = "twitter" };

            var rxtweets = twitterrservicelayer.GetTweetsByRadius(new Usoniandream.WindowsPhone.LocationServices.SearchCriterias.Twitter.SearchByRadius(new GeoCoordinate(40.74917, -73.98529), 0.5))
           .Take(20)
           .ObserveOnDispatcher()
           .Finally(() =>
           {
               PivotItems.Add(tweets);
               IsDataLoading = false;
           })
           .Subscribe(
                // result
               x =>
               {
                   tweets.Items.Add(x);
               },
                // exception
               ex =>
               {
                   // handle exception..
               });
        }

Current framework contents (as of 2012-05-03)

Core libraries:

  • Usoniandream.WindowsPhone.Extensions
  • Usoniandream.WindowsPhone.GeoConverter
  • Usoniandream.WindowsPhone.LocationServices

Data libraries:

  • Usoniandream.WindowsPhone.LocationServices.Bing
  • Usoniandream.WindowsPhone.LocationServices.Commute
  • Usoniandream.WindowsPhone.LocationServices.Flickr 
  • Usoniandream.WindowsPhone.LocationServices.Goteborg
  • Usoniandream.WindowsPhone.LocationServices.Nokia
  • Usoniandream.WindowsPhone.LocationServices.Orebro 
  • Usoniandream.WindowsPhone.LocationServices.Stockholm
  • Usoniandream.WindowsPhone.LocationServices.Stockholm.AR
  • Usoniandream.WindowsPhone.LocationServices.Twitter

The framework libraries, source code and sample app are all on GitHub: https://github.com/peterdrougge/Usoniandream.WIndowsPhone.LocationServices

No comments: