IT tutorials
 
Mobile
 

Windows Phone 8 : Building Location Aware Apps - A Walkthrough of the Location Viewer Sample (part 2) - Displaying Location Using the GeoLocationView Page

1/27/2015 3:10:55 AM
- How To Install Windows Server 2012 On VirtualBox
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire

Displaying Location Using the GeoLocationView Page

The view has two buttons, which are bound to the viewmodel’s StartCommand and StopCommand (see Listing 1).

The GeoLocationView contains several TextBlock elements that are bound to viewmodel properties.

A Slider is bound to the viewmodel’s SampleIntervalMs property, allowing the user to control the sample frequency.

A Windows Phone Toolkit ToggleSwitch is bound to the viewmodel’s UseMockLocator property and changes the IGeoLocator implementation that is used during tracking.

LISTING 1. GeoLocationView Page (excerpt showing main content panel)


<StackPanel Grid.Row="1" Margin="21,30,21,0">
    <StackPanel Grid.Row="1" Margin="21,0,21,0">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="60" />
            <RowDefinition Height="60" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <TextBlock Text="latitude"
                        Style="{StaticResource LatLongTitleStyle}"
                        VerticalAlignment="Center" />
        <TextBlock Text="{Binding GeoCoordinate.Latitude, StringFormat=\{0:F4\}}"
                        Style="{StaticResource LatLongStyle}"
                        Grid.Row="1"/>
        <TextBlock Text="longitude"
                        Style="{StaticResource LatLongTitleStyle}"
                        Grid.Column="1" VerticalAlignment="Center" />
        <TextBlock Text="{Binding GeoCoordinate.Longitude, StringFormat=\{0:F4\}}"
                        Style="{StaticResource LatLongStyle}"
                        Grid.Row="1" Grid.Column="1" />
    </Grid>

    <TextBlock Text="{Binding PositionStatus}"
                        Style="{StaticResource PhoneTextNormalStyle}"
                        Foreground="{StaticResource PhoneAccentBrush}"
                        Height="50" Margin="0" />
    <TextBlock Text="sample interval in milliseconds (0 for realtime)"
                Style="{StaticResource LabelTextStyle}"
                FontSize="{StaticResource PhoneFontSizeSmall}"/>
    <Slider Minimum="0"
            Maximum="10000"
            Value="{Binding SampleIntervalMs, Mode=TwoWay}"
            IsEnabled="{Binding CanStart}"
            LargeChange="1000" SmallChange="1000"/>
    <TextBlock Text="{Binding SampleIntervalMs}" Width="100" Height="50"
                HorizontalAlignment="Left"
                Style="{StaticResource PhoneTextNormalStyle}"/>

    <TextBlock Text="{Binding Message}" Height="50"
                Style="{StaticResource PhoneTextNormalStyle}"/>

    <toolkit:ToggleSwitch Header="mock locator"
        IsChecked="{Binding UseMockLocator, Mode=TwoWay}"
        IsEnabled="{Binding CanStart}"/>

    <StackPanel Orientation="Horizontal">
        <Button Content="Start"
                Command="{Binding StartCommand}"
                Margin="0,20,0,0" Width="150" HorizontalAlignment="Left"/>
        <Button Content="Stop"
                Command="{Binding StopCommand}"
                Margin="0,20,0,0" Width="150" HorizontalAlignment="Left"/>
    </StackPanel>


</StackPanel>


Tapping the Start button causes the current location to be displayed whenever the IGeoLocator object’s PositionChanged event is raised (see Figure 1).

Image

FIGURE 1 GeoLocationView page.

The OS displays an indicator in the system tray when location tracking is engaged. In the sample this occurs when the mock locator is turned off.

Civic Address Resolution

CivicAddressResolver is supposed to be able to resolve a street address from a geographic coordinate. It has not, however, been fully implemented yet and is unable to resolve an address.


Note

In the 8.0 release of the Windows Phone OS, the CivicAddressResolver class has not been fully implemented.


The GeoLocationViewModel class demonstrates how to use the CivicAddressResolver, but the CivicAddressResolver.ResolveAddressCompleted handler always receives an unknown address value.

 
Others
 
- Windows Phone 8 : Building Location Aware Apps - A Walkthrough of the Location Viewer Sample (part 1) - GeoLocationViewModel Class
- Windows Phone 8 : Building Location Aware Apps - Getting Started with Location (part 3) - Code-Driven Location Simulation
- Windows Phone 8 : Building Location Aware Apps - Getting Started with Location (part 2) - Background Location Tracking
- Windows Phone 8 : Building Location Aware Apps - Getting Started with Location (part 1) - Geolocator Class
- Windows Phone 8 : Building Location Aware Apps - Location Sensing Technologies
- Windows Phone 8 : Range Controls (part 2) - Progress Indicator, Slider , ScrollBar
- Windows Phone 8 : Range Controls (part 1) - ProgressBar
- Windows Phone 8 : Items Controls - ListBox, ComboBox
- Windows Phone 8 : LinkedIn (part 3) - Posting a Message, The Feeds Filter
- Windows Phone 8 : LinkedIn (part 2) - Accessing LinkedIn Content, Responding to a LinkedIn Post
 
25 Inspiring Game of Thrones Quotes
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
programming4us programming4us
 
Popular tags
 
Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS