This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
namespace SingletonSample | |
{ | |
class Program | |
{ | |
static void Main(string[] args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
namespace SingletonSample | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Task.Run(async () => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
namespace SingletonSample | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
namespace SingletonSample | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace SingletonSample | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
SingletonClass.Instance.Initialize(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public MapPage() | |
{ | |
// パディングを追加する | |
Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0); | |
// 検索バーと地図コントロールを作成し、StackLayoutへ設定する | |
searchBar = new SearchBar(); | |
map = new Map { IsShowingUser = true }; | |
var stack = new StackLayout(); | |
stack.Children.Add(searchBar); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async void OnSearchButtonPressed(object sender, EventArgs e) | |
{ | |
// 検索バーから入力された地名から緯度・経度を取得する | |
var positions = await geocoder.GetPositionsForAddressAsync(searchBar.Text); | |
// 座標は複数とれる可能性があるが、今回は先頭の座標を利用する | |
var position = positions.FirstOrDefault(); | |
// 座標が一つ以上とれていた場合のみ以下を処理する | |
if (position != null) | |
{ | |
// 該当地点へ移動する |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public MapPage() | |
{ | |
// 検索バーと地図コントロールを作成し、StackLayoutへ設定する | |
searchBar = new SearchBar(); | |
map = new Map { IsShowingUser = true }; | |
var stack = new StackLayout(); | |
stack.Children.Add(searchBar); | |
stack.Children.Add(map); | |
// ページコンテンツとしてStackLayoutを登録する | |
Content = stack; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// 検索条件入力コントロール。入力された値をイベントハンドラ内から取得するためメンバ変数に保持しておく | |
/// </summary> | |
private SearchBar searchBar; | |
/// <summary> | |
/// 地図コントロール。検索結果から該当地点へ移動などを行うためメンバ変数に保持しておく | |
/// </summary> | |
private Map map; | |
/// <summary> | |
/// Geocoding処理は非同期で実施するため、ローカル変数ではなくメンバ変数に保持しておく |