Today I'm starting a series of post about Criterion Factory in the Bing Maps service in the WP7Contrib. I'm not sure how many posts there will be but I expect there to be a few, every time I add one I'll update the list below.
Rich & I have written several posts already about using the Bing Maps service, these have focused around the Location, Routes & Search functionality provided by the Bing Maps REST API and how easily you can get data back without having to deal with a single HttpWebRequest!. If you've read any of these posts you'll have notice the use of the Criterion Factory to construct the query passed to the service methods.
Put simply the Criterion Factory is there to help construct queries because the number of parameters can be confusing and you won't always need to specify every parameter for a particular use case.
A quick refresh, shown below is a prime example of how to use the Bing Maps Wrapper service, it's returning the current location for a post code (zip code):
As I said I'll update the list below with every post about the Criterion Factory:
1. Location search by Latitude & Longitude
2 .Location search by Address
3. Calculating a Route
Rich & I have written several posts already about using the Bing Maps service, these have focused around the Location, Routes & Search functionality provided by the Bing Maps REST API and how easily you can get data back without having to deal with a single HttpWebRequest!. If you've read any of these posts you'll have notice the use of the Criterion Factory to construct the query passed to the service methods.
Put simply the Criterion Factory is there to help construct queries because the number of parameters can be confusing and you won't always need to specify every parameter for a particular use case.
A quick refresh, shown below is a prime example of how to use the Bing Maps Wrapper service, it's returning the current location for a post code (zip code):
public partial class MainPage : PhoneApplicationPage { private readonly IBingMapsService bingMapsService = null; // Constructor public MainPage() { InitializeComponent(); this.bingMapsService = new BingMapsService("Your credentials id", "Your app id"); } private void getAddress_Click(object sender, RoutedEventArgs e) { var criterion = CriterionFactory.CreateLocationSearchForAddress(this.postCode.Text); this.bingMapsService.SearchForLocationUsingAddress(criterion) .ObserveOnDispatcher() .Subscribe(result => { this.address.Text = result.Locations[0].Address.Locality; this.address.Text += Environment.NewLine; this.address.Text += result.Locations[0].Address.PostalCode; this.address.Text += Environment.NewLine; this.address.Text += result.Locations[0].Address.AdminDistrict; this.address.Text += Environment.NewLine; this.address.Text += result.Locations[0].Address.CountryRegion; }); } }
As I said I'll update the list below with every post about the Criterion Factory:
1. Location search by Latitude & Longitude
2 .Location search by Address
3. Calculating a Route
Comments
Post a Comment