1
私はアンドロイドまたはIOSのいずれかのマップを開くことになっているアプリを開発しています。 私が直面している問題(Androidでは、まだテストされていないIOS)は、定義された場所ではなく、自分の場所と思われる場所と同じ場所に常にマップを開きます。ここ は、あなたが私を助けることができれば、私は私のアプリに戻ったとき、私は同じことを選択することができるように、このstoresList.SelectedItem = null;
を配置しなければならないのどこリストの項目が選択解除されていません。またなぜ地図が同じロケーションにあるのですか? Xamarin.Forms()
public MainPage()
{
InitializeComponent();
storesList.BackgroundColor = Color.CornflowerBlue;
storesList.SeparatorColor=Color.White;
storesList.ItemSelected += CellSelected;
storesList.ItemTemplate = new DataTemplate(() =>
{
var storeCell = new StoreCell();
storeCell.SetBinding(StoreCell.NameProperty, "Name");
storeCell.SetBinding(StoreCell.LocationProperty, "Location");
storeCell.SetBinding(StoreCell.ScheduleProperty, "Schedule");
return storeCell;
});
Stores = new ObservableCollection<Store>();
Store store1 = new Store
{
Name = "Pombal",
Location = new Coordinate(39.9143958, -8.6297282).ToString()
};
Store store2 = new Store
{
Name = "Unknown",
Location = new Coordinate(39.7301803, -8.8438668).ToString(),
Schedule = "09:00-12:30/13:30-18:00"
};
Stores.Add(store1);
Stores.Add(store2);
Stores.Add(store1);
Stores.Add(store2);
Stores.Add(store1);
Stores.Add(store2);
Stores.Add(store1);
Stores.Add(store2);
storesList.ItemsSource = Stores;
}
void CellSelected(object sender, SelectedItemChangedEventArgs e)
{
var address = ((Store)e.SelectedItem).Location.Replace(" ", "");
//storesList.SelectedItem = null;
Uri uri;
switch (Device.RuntimePlatform)
{
case Device.iOS:
uri = new Uri(string.Format("http://maps.apple.com/?q={0}", address));
System.Diagnostics.Debug.WriteLine(uri);
Device.OpenUri(uri);
break;
case Device.Android:
uri = new Uri("geo:" + address);
System.Diagnostics.Debug.WriteLine(uri);
Device.OpenUri(uri);
break;
}
}
...私のコードですあなたは正しくマップのURLを構築していないアイテム私は前のように(私はそれを持っている場所、それが機能していない、私はnull参照の例外を取得)