2017-12-18 10 views
1

나는 안드로이드 나 IOS 중 하나에서지도를 여는 앱을 개발 중입니다. 내가 겪고있는 문제 (안드로이드, 아직 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을 구성하지 않는

답변

2

(내가, 내가 null 참조 예외가 그것을 얻을 수있는 경우 작동하지 않습니다) :

https://www.google.com/maps/search/?api=1&query=47.5951518,-122.3316393 

Docs

관련 문제