/// <summary> /// Initializes a new instance of the <see cref="ShopView"/> class. /// </summary> /// <param name="shop">The shop.</param> /// <param name="location">The location.</param> /// <param name="style">The style.</param> public ShopView(Shop shop, GeocodeLocation location, Style style) { this.Shop = shop; this.Pin = new CustomPushPin(location.Location); Pin.Pin.Style = style; ToolTipService.SetToolTip(Pin.Pin, String.Format("{0}\r\n{1}", shop.Name, shop.Address)); }
/// <summary> /// Handles the Loaded event of the myMap control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private async void myMap_Loaded(object sender, RoutedEventArgs e) { try { this.MyMap = (Map)sender; Geolocator geolocator = new Geolocator(); //used to obtain user location Geoposition position = await geolocator.GetGeopositionAsync(); double latitude = position.Coordinate.Point.Position.Latitude; double longitude = position.Coordinate.Point.Position.Longitude; Location location = new Location(latitude, longitude); SearchManager searchManager = MyMap.SearchManager; ReverseGeocodeRequestOptions requestOptions = new ReverseGeocodeRequestOptions(location); LocationDataResponse response; do { response = await searchManager.ReverseGeocodeAsync(requestOptions); } while (response.LocationData.Count == 0 || response.LocationData == null); GeocodeLocation currentLocation = response.LocationData[0]; //place a PushPin at the right place (user) CustomPushPin userPin = new CustomPushPin(location); userPin.Pin.Style = this.Resources["PushPinStyle"] as Style; //create the associated toolTip ToolTipService.SetToolTip(userPin.Pin, "Vous"); MyMap.Children.Add(userPin.Pin); MyMap.ZoomLevel = 12; MyMap.Center = location; //used to retrieve shops PagesJaunesShopRetriever retriever = new PagesJaunesShopRetriever(); bool nothing = await retriever.GetShops(currentLocation.Address.Locality, this.Model); this.shopsViewSource.Source = this.Model.Shops; this.ShopViews = new List <ShopView>(); //used to display shops this.ShopViews = await this.createShopViews(this.Model.Shops, searchManager); foreach (ShopView shopView in this.ShopViews) { this.MyMap.Children.Add(shopView.Pin.Pin); } } catch (Exception ex) { } }