Skip to content

Instantly share code, notes, and snippets.

View anuith's full-sized avatar
💭
Hello World

Thiwakorn anuith

💭
Hello World
View GitHub Profile
@anuith
anuith / gist:2986776
Created June 25, 2012 05:23
Windows Phone Hackathon : Bing Map Sample - UI - XML namespaces
xmlns:map=“clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps”
xmlns:location=”clr-namespace:System.Device.Location;assembly=System.Device”
@anuith
anuith / gist:2986865
Created June 25, 2012 05:42
Windows Phone Hackathon : Bing Map Sample - UI - Map only
<map:Map x:Name=”Map_Main” d:LayoutOverrides=”Width” Grid.Row=”1”
ZoomLevel=”5” Grid.ColumnSpan=”3”
CredentialsProvider=”AtOVDShdO3A0XtPeKnHLpDHjXsr2vrpLD_hJnxqXMmoT7JfWrmmqtygJEQ9b5Ts3”>
<map:Map.Center>
<location:GeoCoordinate Longitude=”100.547369” Latitude=”13.739239”/>
</map:Map.Center>
<map:Pushpin x:Name=”PushPin_Main”>
<map:Pushpin.Location>
<location:GeoCoordinate Longitude=”100.547369” Latitude=”13.739239”/>
</map:Pushpin.Location>
@anuith
anuith / gist:2986876
Created June 25, 2012 05:46
Windows Phone Hackathon : Bing Map Sample - UI - Application Bar
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem IsEnabled="True" Text="reset map" Click="ApplicationBarMenu_Reset_Click"/>
</shell:ApplicationBar.MenuItems>
<shell:ApplicationBarIconButton IconUri="/icons/appbar.check.rest.png" IsEnabled="True" Text="find me" Click="ApplicationBarButton_FindMe_Click"/>
<shell:ApplicationBarIconButton IconUri="/icons/appbar.add.rest.png" IsEnabled="True" Text="zoom in" Click="ApplicationBarButton_ZoomIn_Click"/>
<shell:ApplicationBarIconButton IconUri="/icons/appbar.minus.rest.png" IsEnabled="True" Text="zoom out" Click="ApplicationBarButton_ZoomOut_Click"/>
<shell:ApplicationBarIconButton IconUri="/icons/appbar.favs.rest.png" IsEnabled="True" Text="map mode" Click="ApplicationBarButton_MapMode_Click"/>
</shell:ApplicationBar>
@anuith
anuith / gist:2986919
Created June 25, 2012 06:07
Windows Phone Hackathon : Bing Map Sample - Code - Variables
private readonly GeoCoordinate defaultLocation =
new GeoCoordinate(13.739239, 100.547369);
private const double defaultZoomLevel = 5;
private GeoCoordinateWatcher watcher;
@anuith
anuith / gist:2986924
Created June 25, 2012 06:08
Windows Phone Hackathon : Bing Map Sample - Code - FindMe & ResetMap (Incompleted; continue on: https://gist.github.com/2986930 )
private void FindMe() {
// Reinitialize the GeoCoordinateWatcher
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
watcher.MovementThreshold = 100;//distance in metres
// Add event handlers for StatusChanged and PositionChanged events
watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
// Start data acquisition
@anuith
anuith / gist:2986930
Created June 25, 2012 06:10
Windows Phone Hackathon : Bing Map Sample - Code - Watcher Events (continued from https://gist.github.com/2986924 )
private void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e) {
Deployment.Current.Dispatcher.BeginInvoke(() => LocationChanged(e));
}
private void LocationChanged(GeoPositionChangedEventArgs<GeoCoordinate> e) {
GeoCoordinate location = e.Position.Location;
Map_Main.SetView(location, 15);
PushPin_Main.Location = location;
PushPin_Main.Visibility = System.Windows.Visibility.Visible;
@anuith
anuith / gist:2986933
Created June 25, 2012 06:11
Windows Phone Hackathon : Bing Map Sample - Code - Button_Go_Click
private void Button_Go_Click(object sender, RoutedEventArgs e)
{
if (watcher != null)
{
watcher.Stop();
}
double lat, lon;
if(!double.TryParse(TextBox_Lat.Text, out lat)) {
@anuith
anuith / gist:2986936
Created June 25, 2012 06:12
Windows Phone Hackathon : Bing Map Sample - Code - Application Bar Events
private void ApplicationBarMenu_Reset_Click(object sender, System.EventArgs e)
{
ResetMap();
}
private void ApplicationBarButton_FindMe_Click(object sender, System.EventArgs e)
{
FindMe();
}
@anuith
anuith / gist:2990812
Created June 25, 2012 19:46
Windows Phone Hackathon : Bing Map Sample V2 - UI - ListBox
<ListBox x:Name="ListBox_Places" ItemTemplate="{StaticResource PlacesItemTemplate}" SelectionChanged="ListBox_Places_SelectionChanged"/>
@anuith
anuith / gist:2990825
Created June 25, 2012 19:49
Windows Phone Hackathon : Bing Map Sample V2 - UI - Application Bar
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem IsEnabled="True" Text="change to aerial map" Click="ApplicationBarMenuItem_MapMode_Click"/>
</shell:ApplicationBar.MenuItems>
<shell:ApplicationBarIconButton IconUri="/icons/appbar.feature.search.rest.png" IsEnabled="False" Text="direction" Click="ApplicationBarButton_Direction_Click"/>
<shell:ApplicationBarIconButton IconUri="/icons/appbar.check.rest.png" IsEnabled="True" Text="find me" Click="ApplicationBarButton_FindMe_Click"/>
<shell:ApplicationBarIconButton IconUri="/icons/appbar.cancel.rest.png" IsEnabled="True" Text="clear" Click="ApplicationBarButton_Clear_Click"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>