Page 74 - MSDN Magazine, July 2017
P. 74
Close the Maps app and go back to the FoodFinder app. This time, make sure that the Show Traffic checkbox is checked. Click Launch Map again to see that
traffic data is rendered onto the
the Windows Store app, refer to the documentation on Windows Dev Center at bit.ly/2pPJvaA.
map. If not, then Bing might not have traffic data for that particular location.
Much more can be done with the Maps app. In fact, the full function- ality exposed by the Web version of Bing Maps is also accessible to the Maps app and, as a rule, follows the same parameter name and val- ue format. For more information on how to build a Bing Maps URL, see bit.ly/1MIoJ5K.
More Than Maps
While mapping adds significant value to this app, there are many food-finding apps available in the Windows Store. It would be ben- eficial to differentiate this app by adding a unique feature: music search. For example, if St. Louis were in the Location textbox, users could search for songs about St. Louis and listen to music about their destination. The app will offer users a chance to search for songs with the name of the location in the title. Protocol activation makes it easy to incorporate searches from the Windows Store into apps.
To accomplish this, add the fol- lowing code to the event handler for the btnSearchMusic_Click event:
private async void btnSearchMusic_ Click(object sender, RoutedEventArgs e) {
string uriString = string.Format( $"ms-windows-store:// search/?query={txtLocation. Text}&type=Songs");
Uri uri = new Uri(uriString);
await Launcher.LaunchUriAsync(uri); }
Run the app once again, enter a city name in the Location text- box, and click Search Music. The Windows Store app should launch and display a search of songs with the city name in the title. For instance, if a user entered “St. Louis” as the location, the results would look like what’s shown in Figure 6.
For more information about the parameters that can be passed to
Figure 5 Results for Pizza in Bronx, N.Y.
68 msdn magazine
Modern Apps
Figure 6 Windows Store App Music Section with St. Louis in Titles of Songs