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:2990841
Created June 25, 2012 19:51
Windows Phone Hackathon : Bing Map Sample V2 - UI - Map only
<map:Map x:Name="Map_Main" d:LayoutOverrides="Width" Grid.Row="0"
ZoomLevel="5.5" Grid.ColumnSpan="3" Mode="Road"
CredentialsProvider="AtOVDShdO3A0XtPeKnHLpDHjXsr2vrpLD_hJnxqXMmoT7JfWrmmqtygJEQ9b5Ts3" ZoomBarVisibility="Visible">
<map:Map.Center>
<location:GeoCoordinate Longitude="100.547369" Latitude="13.739239"/>
</map:Map.Center>
<map:MapLayer>
<map:Pushpin x:Name="PushPin_Me" Foreground="White" Background="{StaticResource PhoneAccentBrush}" Content="i'm here!" Visibility="Collapsed">
<map:Pushpin.Location>
<location:GeoCoordinate Longitude="100.547369" Latitude="13.739239"/>
@anuith
anuith / gist:2990847
Created June 25, 2012 19:53
Windows Phone Hackathon : Bing Map Sample V2 - UI - Page Resource
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="PlacesItemTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="140"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition MinHeight="30"/>
<RowDefinition MinHeight="30"/>
@anuith
anuith / gist:2990995
Created June 25, 2012 20:21
Windows Phone Hackathon : Bing Map Sample V2 - Code - FindMe
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);
@anuith
anuith / gist:2991006
Created June 25, 2012 20:25
Windows Phone Hackathon : Bing Map Sample V2 - Code - ClearMap
private void ClearMap()
{
Map_Main.SetView(defaultLocation, defaultZoomLevel);
Map_Main.Mode = new RoadMode();
PushPin_Me.Location = defaultLocation;
PushPin_Me.Visibility = System.Windows.Visibility.Collapsed;
PushPin_Dest.Visibility = System.Windows.Visibility.Collapsed;
}
@anuith
anuith / gist:2991076
Created June 25, 2012 20:40
Windows Phone Hackathon : Bing Map Sample V2 - Code - Watcher StatusChanged
private void watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
{
Deployment.Current.Dispatcher.BeginInvoke(() => LocationStatusChanged(e));
}
private void LocationStatusChanged(GeoPositionStatusChangedEventArgs e)
{
ApplicationBarIconButton ApplicationBarButton_FindMe =
ApplicationBar.Buttons[1] as ApplicationBarIconButton;
switch (e.Status)
@anuith
anuith / gist:2991087
Created June 25, 2012 20:41
Windows Phone Hackathon : Bing Map Sample V2 - Code - Watcher PositionChanged
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;
PushPin_Me.Location = location;
@anuith
anuith / gist:2991098
Created June 25, 2012 20:43
Windows Phone Hackathon : Bing Map Sample V2 - Code - Application Bar Events
private void ApplicationBarButton_FindMe_Click(object sender, System.EventArgs e)
{
PivotRoot.SelectedIndex = 0;
FindMe();
}
private void ApplicationBarButton_Direction_Click(object sender, EventArgs e)
{
BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();
@anuith
anuith / gist:2991191
Created June 25, 2012 20:57
Windows Phone Hackathon : Bing Map Sample V2 - Code - ListBox SelectionChanged
private void ListBox_Places_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListBox listbox = sender as ListBox;
if(listbox.SelectedIndex < 0) return;
// ดึงค่า item ที่ถูกเลือก มาจาก listbox
Place item = listbox.SelectedItem as Place;
// เลื่อน pivot ให้กลับไปยังหน้า map
PivotRoot.SelectedIndex = 0;
@anuith
anuith / PrettyDate.js
Created July 22, 2012 15:42
Javascript Pretty Date formatter
/*
Pretty Date script modified from John Resig here http://ejohn.org/blog/javascript-pretty-date
*/
function relativeDateTime (tdate) {
var system_date;
if (typeof (tdate) === "number") {
tdate = new Date(tdate).toString();
}
if (navigator.userAgent.match(/MSIE\s([^;]*)/)) {
@anuith
anuith / ThailandWeather.json
Created December 18, 2012 03:16
Sample weather data from wunderground API
{
"response": {
"version": "0.1"
,"termsofService": "http://www.wunderground.com/weather/api/d/terms.html"
,"features": {
"geolookup": 1
}
, "results": [
{
"name": "Aranyaprathet",