コード例 #1
0
        /// <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

            }
        }
コード例 #2
0
ファイル: Reference.cs プロジェクト: xxjeng/nuxleus
 /// <remarks/>
 public void FindAddressAsync(FindAddressSpecification specification, object userState) {
     if ((this.FindAddressOperationCompleted == null)) {
         this.FindAddressOperationCompleted = new System.Threading.SendOrPostCallback(this.OnFindAddressOperationCompleted);
     }
     this.InvokeAsync("FindAddress", new object[] {
                 specification}, this.FindAddressOperationCompleted, userState);
 }
コード例 #3
0
ファイル: Reference.cs プロジェクト: xxjeng/nuxleus
 /// <remarks/>
 public System.IAsyncResult BeginFindAddress(FindAddressSpecification specification, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("FindAddress", new object[] {
                 specification}, callback, asyncState);
 }
コード例 #4
0
ファイル: Reference.cs プロジェクト: xxjeng/nuxleus
 /// <remarks/>
 public void FindAddressAsync(FindAddressSpecification specification) {
     this.FindAddressAsync(specification, null);
 }
コード例 #5
0
ファイル: Reference.cs プロジェクト: xxjeng/nuxleus
 public FindResults FindAddress(FindAddressSpecification specification) {
     object[] results = this.Invoke("FindAddress", new object[] {
                 specification});
     return ((FindResults)(results[0]));
 }