Introduction



Home Screen :

Name of Experiment : My Location

Exp No : MC4

Background : Student should have a basic knowledge of C#.

Summary : Now days, due to advancement in technology people are always concerned about their location in terms of longitude, latitude and altitude. Where they Are? Which places are nearby Him? These are very common question which is answered spontaneously by their Smartphone or Tab with the help of A-GPS (Assisted GPS) technology embedded in it.

Learning Objective : Student is able to get his location, in terms of longitude, latitude, and altitude along with Current Timestamp.

Target

Target Platform : This experiment is tested on Windows Phone Emulator and Nokia Lumia 800.

Procedure

SourceCode

Source Code : Comments :
MainPage.xaml
<Grid x:Name="LayoutRoot" Background="CornflowerBlue">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ExperimentTitle" Text="Exp No.MC4" TextAlignment="Right"
Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="ApplicationTitle" Text="Mobile Computing" Style="{StaticResource
PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="My Location " Margin="9,-7,0,0"
Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>

<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock Height="247" TextWrapping="Wrap" HorizontalAlignment="Left"
Margin="43,152,0,0" Name="textBlock1" Text="" VerticalAlignment="Top" Width="352" />
</Grid>
</Grid>



<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel Margin="12,6,6,70" Orientation="Vertical" >
<TextBlock x:Name="tbkeyDeployed" Text="" Height="43" />
<TextBlock x:Name="tbkeyPresent" Text="" Height="43"/>
<TextBlock x:Name="tbPowerS" Text="" Height="43"/>
<TextBlock x:Name="tbApplicationCurrentMem" Text="" Height="43"/>
<TextBlock x:Name="tbApplicationPeakMem" Text="" Height="43"/>
<TextBlock x:Name="tbDeviceMem" Text="" Height="43"/>
<TextBlock x:Name="tbDeviceName" Text="" Height="43"/>
<TextBlock x:Name="tbDeviceManu" Text="" Height="43"/>
<TextBlock x:Name="tbFWareVer" Text="" Height="43"/>
<TextBlock x:Name="tbHwVer" Text="" Height="43"/>
<TextBlock x:Name="tbMultiVideo" Text= " " Height="43"/>
</StackPanel> </Grid> </Grid>







 Exp No MC4(Experiment title)



 Mobile Computing(Application title)




 My Location(Page title)
MainPage.xaml.cs
using System;
using Microsoft.Phone.Controls;
using System.Device.Location;

namespace GPS_Apps

{
public partial class GPS : PhoneApplicationPage
{
string txt = "";
public GPS()
{
InitializeComponent();
Update();
}
void Update() {
GeoCoordinateWatcher geoWatcher =
new GeoCoordinateWatcher();
geoWatcher.PositionChanged+=new
EventHandler<GeoPositionChangedEventArgs<GeoCoordinate><
(geoWatcher_PositionChanged);
geoWatcher.Start();
}
public void geoWatcher_PositionChanged
(object sender,GeoPositionChangedEventArgs<GeoCoordinate> e)
{
txt = String.Format("Latitude: {0:F3} \r\n" +
"Longitude: {1:F3}\r\n" +
"Altitude:{2}\r\n\r\n" + "{3}",
e.Position.Location.Latitude,
e.Position.Location.Longitude,
e.Position.Location.Altitude,e.Position.Timestamp);
textBlock1.Text = txt;
}
}
}


 Add Reference for Microsoft.Phone.Info

Snapshots





Observation

Observation : It is observed that now, student can able to obtain their own location at any place using this experiment.

Video Link

For Windows Phone

Download

Right Click Here And Select Save Target For Entire Download :

Location Info Experiment