/// <summary> /// Version of FindLocation that searches using a LatLong object /// </summary> /// <param name="aLatLong">a LatLong</param> /// <returns></returns> public Location FindLocation(LatLong aLatLong) { Location[] location = null; try { if (aLatLong == null) { throw new System.ArgumentNullException("LatLong cannot be null"); } //OK find something FindSpecification fs = new FindSpecification(); fs.DataSourceName = "MapPoint.NA"; LatLong locationLatLong = aLatLong; GetInfoOptions infoOptions = new GetInfoOptions(); location = theMapPointFindService.GetLocationInfo(locationLatLong, MAPPOINT_NA, infoOptions); } catch (ArgumentNullException e) { throw e; // rethrow for app to handle } catch (Exception e) { throw e; // rethrow for app to handle } return location[0]; // zero position should be the best match }
/// <summary> /// Find a location like an address (1500 Central rd., Chicago, IL) or landmark (Sears tower or Navy Pier) /// </summary> /// <param name="locationString">address or landmark</param> /// <returns>Location</returns> public Location FindLocation(string locationString) { Location[] location = null; try { if (locationString == "") { throw new System.ArgumentNullException("Location cannot be empty"); } FindSpecification myFindSpec = new FindSpecification(); myFindSpec.InputPlace = locationString; myFindSpec.DataSourceName = "MapPoint.NA"; FindResults results = theMapPointFindService.Find(myFindSpec); // if there is no result found try it as an address instead if (results.NumberFound == 0) { // if you want to use addresses instead you can use the code below Address address = theMapPointFindService.ParseAddress(locationString, "USA"); FindAddressSpecification myFindASpec = new FindAddressSpecification(); myFindASpec.DataSourceName = "MapPoint.NA"; myFindASpec.InputAddress = address; results = theMapPointFindService.FindAddress(myFindASpec); } // at this point a place (e.g. Sears Tower) or an address was not found so // return an error if (results.NumberFound == 0) { throw new System.ArgumentNullException("Location cannot be found"); } return results.Results[0].FoundLocation; } catch (ArgumentNullException e) { throw e; // rethrow for app to handle } catch (Exception e) { throw e; // rethrow for app to handle } }
/// <remarks/> public void FindAsync(FindSpecification specification, object userState) { if ((this.FindOperationCompleted == null)) { this.FindOperationCompleted = new System.Threading.SendOrPostCallback(this.OnFindOperationCompleted); } this.InvokeAsync("Find", new object[] { specification}, this.FindOperationCompleted, userState); }
/// <remarks/> public void FindAsync(FindSpecification specification) { this.FindAsync(specification, null); }
/// <remarks/> public System.IAsyncResult BeginFind(FindSpecification specification, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("Find", new object[] { specification}, callback, asyncState); }
public FindResults Find(FindSpecification specification) { object[] results = this.Invoke("Find", new object[] { specification}); return ((FindResults)(results[0])); }