Overview of the Bing Maps Trip Optimizer sample
This document describes the fundamental characteristics of the Bing Maps Trip Optimizer project, for example, how it's created and structured, and how it's built.
The sample code that corresponds to this document is found in the Bing Maps Trip Optimizer Sample.
If you've downloaded and extracted the sample, you can open the TripOptimizer.sln solution file in Visual Studio, and you'll have the code in front of you. You can also view the source on the Bing Maps trip optimizer sample MSDN Samples Gallery page by selecting the Browse Code tab.
One important project setting in the WinRT Class Library template is the /ZW option, which enables the program to use the Windows Runtime language extensions.
The /ZW option is not compatible with options such as /clr. This means that you can't target both the .NET Framework and the Windows Runtime from the same Visual C++ project.
Every Windows 8.x Store app on the Windows Store comes in the form of an app package. An app package contains a package manifest, which contains information about the app. For example, you can specify its capabilities, which define its access to protected system resources or user data. If you determine that your app requires certain capabilities, use the package manifest to declare them. Bing Maps Trip Optimizer specifies Internet (Client) to enable the app to access the Bing Maps Web services. For more information about app packages and capabilities, see .47EAAAFB-29AF-495C-A2D1-B2FF572D2631
Build a Windows 8.x Store app project as you would build a standard project. (On the menu bar, choose Build, Build Solution). The build step compiles the code and also packages it for use as a Windows 8.x Store app.
After you build the project, you must deploy it. (On the menu bar, choose Build, Deploy Solution). Visual Studio also deploys the project when you run the app from the debugger.
After you deploy the project, pick the Bing Maps Trip Optimizer tile to run the app. Alternatively, from Visual Studio, on the menu bar, choose Debug, Start Debugging. Make sure that TripOptimizerWebApp is the startup project.
A Bing Maps Key is required to run this sample. For information about how to get a Bing Maps Key, see .1cc82ed6-1613-4d64-a0e6-0d9fdca107dc
Here's the workflow of the app.
Enter up to 25 locations for the trip. The first entry specifies both the start and end location.
You can select Parks Demo or Delivery Demo to populate the locations area with predefined values.
Select the method of travel (driving or walking), the distance unit (miles or kilometers), and the optimization method (minimize distance, minimize time, or avoid traffic).
If you want to, specify the inputs to the optimization algorithm and whether to use parallel computation. Parallel computation is enabled by default.
The Advanced Options section is included as a learning tool for developers. These options are not intended to be part of an app.
Use the Bing Maps Representational State Transfer (REST) services to retrieve the latitude and longitude of each location. As part of the response, Bing Maps includes all possibilities that match the location string.
For all locations that have more than one possibility, display all possibilities in the UI and return to step 1.
Use the Bing Maps REST services to retrieve the distance (either driving or walking) from every location to every other location. This step uses the latitude and longitude values that were obtained in step a.
You can interact with the map. When you choose a step or location from the travel directions, the AJAX control moves to that step or location and adds a pushpin to the map.
The following illustration shows a more basic view of the workflow.
The C++ component uses the Bing Maps REST services in two phases. The first phase helps the user verify that Bing Maps has the correct locations. For example, if you specify "Pittsburgh", Bing Maps might return "Pittsburgh, PA," "Pittsburgh, ON," and "Pittsburgh, GA" as the possibilities. When ambiguities are resolved early in the process, the second phase, which retrieves the distance from every point to every other point, can run without encountering ambiguous locations.