Work is to take the bus, a lot of TX certainly to rent a house and buy a house away from the bus station near very much. Who do not want to find a cheap and can have a shuttle to live AH (not the money can directly ignore my dick silk behavior), so I want to do an application, you can search for a location (such as the right neighborhood) can show the location of the shuttle near the search place, in addition to calculate the next distance from these shuttle bus site is how far.
OK, off the topic, let's talk about the development process.
Ever since I got out of the Universal app (Universal app), I knew something was going to happen. Microsoft ambition is not small ah, using the Universal app mode to develop applications, so that unified application between Windows Phone and Windows Store sharing 70% (Microsoft to the data, haha, I do not verify) code, greatly speed up their application in the platform penetration. So don't think about it, now you have to start directly from the Universal app. By the way, Microsoft also has a document for the Universal app, titled "Building a Universal Windows app for Windows and Windows Phones", which is called a universal Windows app (Universal windows a PP). This way of development will always become a technology-led, we will wait and see.
And a lot of it, just as I was building a project in accordance with the Universal Windows app, I got the first surprise when I was ready to do a big job.
1 First accident: Windows Phone 8.1 map and Windows 8.1 Map It's not the same thing now.
How to search and know what to remember, just remember the results. Just a little bit of analysis. Windows Phone 8.1 Development Map Application We will certainly give priority to the Mapcontrol, which is currently based on Microsoft documentation that currently only supports Windows Phone 8.1. It is not possible to try to introduce Mapcontrol and related feature classes in Windows 8.1 projects.
Well, from the beginning, I knew that my universal. The core part of the Windows app (map data processing) must be two parts. That must have started with Windows Phone 8.1. So there is the part of the following article.
2. Changed from universal Windows app to Windows Phone 8.1 app
Please don't ask me why not the Windows Phone Silverlight 8.1 APP. We're going to talk to each other, OK? The future trend is based on the full Windows Runtime architecture of the application okay. Since the beginning of the work, then certainly used to become the mainstream direction of the model AH.
Okay, here it is, the final decision to develop is the Windows Phone 8.1 application.
3. Start building the interface, including the map area, search box, Function button, which is roughly three blocks. The interface is roughly 1:
Figure 1
Well, you said you can't see the search box, that's because the hidden Ah, click the Function button area of the Search button, you can open the search box. As shown in 2.
Figure 2
?
Look at the UI architecture, the tree structure, the tree structure is a
<Page>
???? <Grid>
???????? <TextBox/>
???????? <StackPanel>
???????????? <TextBlock/>
???????????? <MapControl/>
???????? </StackPanel>
???? </Grid>
???? <Page.BottomAppBar>
</Page.BottomAppBar>
</Page>
4. Function realization
4.1 Initialize all shuttle stations
This is mainly to obtain the latitude and longitude information of each shuttle site. First, create a Busstation class, which is primarily a description of the site's information, including latitude and longitude and station names. That's just what I thought. It's a kind of example. For a product, the shuttle site as an object, in fact, can also be different properties, such as the street, the vicinity of any important signs or places, by the shuttle bus time, and so on, these can be attributed to this bus site up. Before the project, it is important to establish the object model first. Just this point I am still learning, interested can see "elephant: Thinking in UML". It tells how to use object-oriented viewpoint to analyze and build model object when facing a project.
With Busstation, we can convert it into the corresponding object Mapicon of the UI, give it the corresponding properties, and then add them to the mapelements in the Mapcontrol, and it can be displayed on the map.
Note that mapelements can add elements in addition to Mapicon, including images, and polygon fences, and so on.
4.2 Display the current map as old factory Center
This feature is initially thought to be centered at the current location. But that's not a good thought. I think there is no need for this function according to the original demand. Do a bit, think still bad, now ready to show is old factory. The main thing about this feature is Trysetviewasync. Her role is to transfer our view center to the current icon location.
This is an asynchronous function. Fully leverages the support for async in the. NET Framework 4.5 and Windows runtime. This complex work is going to be done by the compiler, and we're like using synchronous code to write the logical structure of the application, but the result is that all asynchronous programming has the advantage, but just a little bit of work.
Examples of await and async can refer to http://cc.bingj.com/cache.aspx?q=.net+4.5+await+%e8%af%a6%e8%a7%a3&d=4729151226052614 &mkt=zh-cn&setlang=zh-cn&w=8irfz6sj5uxmkyaa1keeigcszmexxwho
There's not much to talk about here.
4.3 Implementation of search function
Click the Search button, the search box appears, enter the search text, click Enter, trigger the search operation. Searchtextbox_keyup, this event is a search operation. With Maplocationfinder.findlocationsasync we can get all the places and then display them on the map.
Implementation of 4.4 line calculation
Maproutefinder.getdrivingrouteasync use to get a single line. Then choose the line we need, and mark it out for you.
4.5 Implementation of accessibility features
How to get to the next location, zoom in or zoom out on the map implementation.
5. Some problems at this stage
I do not know whether it is the Microsoft API problem, or I did not apply for the reason of the map key, in short, I use Maplocationfinder search feel not good, search out sometimes not want to place, or simply can't search. Also asked on MSDN, some say that the API is not perfect, some say that using Bing's Rest service, let me have time to study again.
Windows Phone 8.1 Map App Development