This question is locked. New answers and comments are not allowed.
Hi,
I followed the example in Telerik demo to search for a location. this is the code behind
#if SILVERLIGHT private string VEKey = "AgWnkUbvO_qS8-uaGDqbJPTTb84q1iDP1If_CHqwPz91-..........."; #endif private MapItemsCollections itemCollection = new MapItemsCollections(); private BingSearchProvider searchProvider; public ViewProperties() { InitializeComponent(); this.landpropertyDomainDataSource.QueryParameters.Add(new Parameter { ParameterName = "propertyid", Value = 4 }); this.landpropertyDomainDataSource.Load(); //this.radMap.Provider = new BingMapProvider(MapMode.Aerial, true, "AgWnkUbvO_qS8-uaGDqbJPTTb84q1iDP1If_CHqwPz91-............"); //this.searchProvider = new BingSearchProvider(); //searchProvider.ApplicationId = "AgWnkUbvO_qS8-uaGDqbJPTTb84q1iDP1If_CHqwPz91-............. //searchProvider.MapControl = this.radMap; #if SILVERLIGHT this.GetVEServiceKey(); #else this.SetProvider(); #endif //SearchRequest request = new SearchRequest(); //request.Query = "W13 0GH"; //this.searchProvider.SearchAsync(request); //searchProvider.SearchCompleted += this.searchProvider_SearchCompleted; } // Initialize Virtual Earth map provider. private void SetProvider() { #if SILVERLIGHT BingMapProvider provider = new BingMapProvider(MapMode.Aerial, true, this.VEKey); #else BingMapProvider provider = new BingMapProvider(MapMode.Aerial, true, BingMapHelper.VEKey); provider.IsTileCachingEnabled = true; #endif this.radMap.Provider = provider; // Init searh provider. searchProvider = new BingSearchProvider(); #if SILVERLIGHT searchProvider.ApplicationId = this.VEKey; #else searchProvider.ApplicationId = BingMapHelper.VEKey; #endif searchProvider.MapControl = this.radMap; searchProvider.SearchCompleted += new EventHandler<SearchCompletedEventArgs>(Provider_SearchCompleted); SearchHandler(); } #if SILVERLIGHT private void GetVEServiceKey() { WebClient wc = new WebClient(); wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); //Uri keyURI = new Uri(URIHelper.CurrentApplicationURL, VEKey); //wc.DownloadStringAsync(keyURI); } void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { // this.VEKey = e.Result; this.SetProvider(); } #endif private void SearchHandler() { string query = "W5 2BP"; if (!string.IsNullOrEmpty(query)) { SearchRequest request = new SearchRequest(); //request.Culture = new System.Globalization.CultureInfo("en-GB"); request.Query = query; this.searchProvider.SearchAsync(request); } } private void Provider_SearchCompleted(object sender, SearchCompletedEventArgs args) { SearchResponse response = args.Response; if (response != null && response.ResultSets.Count > 0) { if (response.ResultSets[0].Results.Count > 0) { this.itemCollection.Clear(); foreach (SearchResultBase result in response.ResultSets[0].Results) { MyMapItem item = new MyMapItem() { Title = result.Name, Location = result.LocationData.Locations[0] }; this.itemCollection.Add(item); } } if (response.ResultSets[0].SearchRegion != null) { // Set map viewport to the best view returned in the search result. this.radMap.SetView(response.ResultSets[0].SearchRegion.GeocodeLocation.BestView); // Show map shape around bounding area if (response.ResultSets[0].SearchRegion.BoundingArea != null) { MapShape boundingArea = response.ResultSets[0].SearchRegion.BoundingArea; boundingArea.Stroke = new SolidColorBrush(Colors.Red); boundingArea.StrokeThickness = 1; this.informationLayer2.Items.Add(boundingArea); } if (response.ResultSets[0].SearchRegion.GeocodeLocation.Address != null && response.ResultSets[0].SearchRegion.GeocodeLocation.Locations.Count > 0) { foreach (Location location in response.ResultSets[0].SearchRegion.GeocodeLocation.Locations) { MyMapItem item = new MyMapItem() { Title = response.ResultSets[0].SearchRegion.GeocodeLocation.Address.FormattedAddress, Location = location }; this.itemCollection.Add(item); } } } } }and here is the other classes i added to the SL app
using System; using System.Collections.ObjectModel; namespace BijansHome.Map.Search { public class MapItemsCollections : ObservableCollection<MyMapItem> { } } using System; using Telerik.Windows.Controls.Map; namespace BijansHome.Map.Search { public class MyMapItem { public Location Location { get; set; } public string Title { get; set; } public string Description { get; set; } } }Can you tell me where I do wrong in the code?
Thanks,
Kam