BrainDump
  Home arrow BrainDump arrow Page 2 - Finding Locations with the MapPoint Web Se...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

Finding Locations with the MapPoint Web Service Find APIs
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-02-21

    Table of Contents:
  • Finding Locations with the MapPoint Web Service Find APIs
  • Finding Addresses
  • Finding Points of Interest Around a Location
  • Finding Points of Interest Along a Route

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Finding Locations with the MapPoint Web Service Find APIs - Finding Addresses


    (Page 2 of 4 )

    While the FindServiceSoap.Find method works well for finding places and geographic entities in general, it doesn’t offer any help to find addresses; use the FindServiceSoap.FindAddress method for that purpose.

    Like any FindServiceSoap.Find method, the FindServiceSoap.FindAddress method takes a specification object of type FindAddressSpecification and inputs a data


    Figure 6-2.  MapPoint Web Service data source browser

    source name field of type String and an Options field of type FindOptions as input fields to expose an InputAddress field of type Address . Table 6-3 shows the fields exposed on the FindAddressSpecification object.

    Table 6-3. Fields exposed in the FindAddressSpecification class

    Field Description
    DataSourceName A string representing the name of the data source in which to search for the address. Example: MapPoint.NA .
    InputAddress The input address to be found. This field is of type Address class.
    Options The search options ( FindOptions object), which include the range of results, the threshold score of results returned, and a flag to identify which objects are desired in the returned results.

    To use a data source to find addresses, it must have the CanFindAddress capability. An address in MapPoint Web Service is always represented as a valid instance of the Address object; the Address class provides fields such as AddressLine , PrimaryCity , SecondaryCity , Subdivision , PostalCode , and CountryRegion to represent a valid address for all countries/regions. When used as input, the address line information of an address is optional. When an address is returned as an output, the address object also provides a formatted address string via the FormattedAddress field.

    Say you want to find the following address:

      1 Microsoft Wa y
      Redmond, WA 98052
      US

    First, you need to create an Address object:

      //Create an address object
      //And assign address values
      Address address = new Address();
      address.AddressLine = "1 Microsoft Way";
      address.PrimaryCity = "Redmond";
      address.Subdivision = "WA";
      address.PostalCode = "98052";
      address.CountryRegion = "US";

    Once the Address object is ready, you can find the address information (such as latitude/longitude, best map view information, etc.) using the FindServiceSoap.FindAddress method:

      //Create a find address specification object
      FindAddressSpecification findAddressSpec = new FindAddressSpecification();
      //Assign input address
      findAddressSpec.InputAddress = address;
      findAddressSpec.DataSourceName = "MapPoint.NA";

      //Call the find address method
      FindResults foundAddressResults = 
       findService.FindAddress(findAddressSpec);

      //Process found results
      if (foundAddressResults.NumberFound > 0)
      {
         if(foundAddressResults.Results[0].FoundLocation.LatLong != null)
           {
             //Process latitude/longitude information
             . . .
           }
      }

    The previous code snippet assumes that you have the FindService object available with proper credentials assigned.

    The FindAddressSpecification also exposes the Options field so that you can control the behavior of the locations returned by this method using the FindOptions class; the FindOptions behavior that we have looked at in the Find method still holds true for this method except that you can only get a maximum of 100 results instead of 500.

    More BrainDump Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Programming MapPoint in .NET," published...
     

    Buy this book now. This article is excerpted from chapter six of the book Programming MapPoint in .NET, written by Chandu Thota (O'Reilly; ISBN: 0596009062). Check it out today at your favorite bookstore. Buy this book now.

    BRAINDUMP ARTICLES

    - Introduction to Office Live Workspace
    - Using MS Excel for One-way Analysis of Varia...
    - Comparing Data Sets Using Statistical Analys...
    - Import Blogger Posts into WordPress Using Wi...
    - Download WordPress from an FTP Server and Ru...
    - Install and Run WordPress in XAMPP Local Host
    - What Windows 7 Brings to the Table
    - Virtualization and Sandbox Detection
    - Advanced Firebug Techniques in Windows XP Ho...
    - Editing CSS with Firebug in Windows XP Home
    - Using Firebug in Windows XP Home
    - Migrating to Exchange Server 2007
    - Using System Restore on a Non-Bootable PC
    - Finding Logged on Users and More Scripting S...
    - Developing Macro Commands in MS Excel





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek