Cover image for Programming MapPoint in .NET

Book description

Interactive web maps generated by MapPoint-Microsoft's popular mapping technology are crucial for businesses in a number of fields, including real estate, package delivery, and commercial air travel. In a word, MapPoint provides businesses with "location." Specifically, it provides an integrated set of products, servers, and services to enable a business to track the precise location of remote assets, thereby reducing operational costs and improving productivity. Whether the asset is a truck, a taxi, or even a field rep, MapPoint can tell you exactly where it is at any time.

Programming MapPoint in .NET from O'Reilly shows you how to use MapPoint to build custom applications for the desktop, the web, and mobile devices. The book also explains how to analyze and share data generated from a wide range of maps, including those that show demographic trends, population density, and sales potential. Chandu Thota, one of Microsoft's main MapPoint developers and the book's author, has organized the material into four major sections, each dedicated to a different MapPoint technology:

  • MapPoint 2004 - calculating routes, rendering data maps, integrating with Global Positioning System (GPS) for obtaining real-time location

  • MapPoint Web Service - techniques for finding points of interest, creating applications using the Find APIs and Route APIs, rendering LineDrive maps and polygons

  • MapPoint Location Server - deployment scenarios, getting real-time location using mobile phones, managing contacts and privacy settings

  • MSN Virtual Earth - the basics of programming with new MSN Virtual Earth APIs

The book provides a jumpstart for working with these technologies, including in-depth discussions about the core concepts and sample code provided in C#. It's ideal for anyone who wants to develop locations-based applications with MapPoint technologies.

The next time you follow online directions to the airport, you can chalk up an assist to MapPoint's state-of-the-art interactive mapping abilities. Better yet, you'll know how to create that same type of map yourself.

Table of Contents

  1. Programming MapPoint in .NET
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. A Note Regarding Supplemental Files
    3. Foreword
    4. Preface
      1. Who Should Read This Book
      2. What's in This Book
        1. Part I, MapPoint 2004
        2. Part II, MapPoint Web Service
        3. Part III, MapPoint Location Server
        4. Part IV, MSN Virtual Earth
        5. Appendixes
      3. Conventions in This Book
      4. Companion Material
      5. Using Code Examples
      6. Other Resources
      7. Safari® Enabled
      8. We'd Like Your Feedback!
      9. Acknowledgments
    5. 1. Hello, MapPoint!
      1. 1.1. Location-Based Application Categories
        1. 1.1.1. Location-Enabled Applications
        2. 1.1.2. Location-Aware Applications
      2. 1.2. Location Application Architectures
        1. 1.2.1. Disconnected Location-Based Applications
        2. 1.2.2. Connected Location-Based Applications
      3. 1.3. Developing Location-Enabled Applications
        1. 1.3.1. Disconnected Applications Using MapPoint 2004
          1. 1.3.1.1. Hello, MapPoint 2004!
        2. 1.3.2. Connected Applications Using MapPoint Web Service
      4. 1.4. Developing Location-Aware Applications
        1. 1.4.1. Disconnected Applications Using MapPoint 2004 and GPS
        2. 1.4.2. Connected Applications Using MapPoint Location Server
      5. 1.5. How It All Fits Together
      6. 1.6. Where Are We?
    6. I. MapPoint 2004
      1. 2. Programming with MapPoint 2004
        1. 2.1. The MapPoint 2004 Object Model
        2. 2.2. Programming with MapPoint 2004 API
          1. 2.2.1. Adding MapPoint 2004 References Using Visual Studio .NET
          2. 2.2.2. Adding MapPoint 2004 References Using TlbImp.EXE
          3. 2.2.3. Finding a Place
            1. 2.2.3.1. Using the get accessor method
            2. 2.2.3.2. Using an enumerator
            3. 2.2.3.3. Programmatically disambiguating the results
          4. 2.2.4. Finding an Address
            1. 2.2.4.1. Parsing a string into valid street address
          5. 2.2.5. Finding Both Places and Addresses
          6. 2.2.6. One UI Finds All
          7. 2.2.7. Finding Points of Interest Around a Location
            1. 2.2.7.1. Categorizing points of interest using the PlaceCategory class
            2. 2.2.7.2. Controlling place category visibility
          8. 2.2.8. Calculating Distance Between Two Locations
        3. 2.3. Programming the MapPoint ActiveX Control
          1. 2.3.1. Adding MapPoint 2004 ActiveX Control
          2. 2.3.2. Initializing the MapPoint 2004 ActiveX Control
          3. 2.3.3. Controlling Toolbars and Panes
          4. 2.3.4. Displaying a Location on a Map
          5. 2.3.5. Working with Pushpins
          6. 2.3.6. Interacting with Maps
            1. 2.3.6.1. Panning maps
            2. 2.3.6.2. Zooming Maps
            3. 2.3.6.3. Tracking mouse clicks
            4. 2.3.6.4. Point to location
            5. 2.3.6.5. Location to point
            6. 2.3.6.6. Processing location selections
            7. 2.3.6.7. Disabling map interaction
          7. 2.3.7. Saving a Map
        4. 2.4. Cleaning Up After You're Done
        5. 2.5. Dealing with Latitude and Longitude
          1. 2.5.1. Hit-Detection in MapPoint 2004
          2. 2.5.2. Determining Time Zone for a Given Location
          3. 2.5.3. Determining the Street Address of a Given Location
        6. 2.6. Routing in MapPoint 2004
          1. 2.6.1. Specifying a Route
          2. 2.6.2. Optimizing a Route
          3. 2.6.3. Calculating a Route
          4. 2.6.4. Personalizing Route Calculations
        7. 2.7. Where Are We?
      2. 3. Working with Data in MapPoint 2004
        1. 3.1. Understanding the MapPoint 2004 Data API
        2. 3.2. Understanding Data Maps
          1. 3.2.1. Understanding Data Map Styles
            1. 3.2.1.1. Location data map
            2. 3.2.1.2. Single-item data map
            3. 3.2.1.3. Multiple item data map
          2. 3.2.2. Understanding the DataSet.DisplayDataMap Method
            1. 3.2.2.1. Defining data map style
            2. 3.2.2.2. Specifying Data Detail
            3. 3.2.2.3. Specifying data range
            4. 3.2.2.4. Specifying custom ranges
            5. 3.2.2.5. Dealing with optional values
        3. 3.3. Working with MapPoint Demographic Data
          1. 3.3.1. Accessing the Demographic Data Categories Programmatically
          2. 3.3.2. Displaying Data Map Using Demographic Data
            1. 3.3.2.1. Displaying a data map
            2. 3.3.2.2. Defining data range type and count
            3. 3.3.2.3. Specifying custom data ranges
            4. 3.3.2.4. Customizing the legend pane
            5. 3.3.2.5. Using the DivideBy field
            6. 3.3.2.6. Using the custom data range to filter data
        4. 3.4. Working with Your Business Data
          1. 3.4.1. Importing External Data
            1. 3.4.1.1. Understanding the DataSets.ImportData method
            2. 3.4.1.2. Importing data from a text file
            3. 3.4.1.3. Helping MapPoint understand your text data
            4. 3.4.1.4. Displaying Data Maps using your data and demographic data
            5. 3.4.1.5. Importing Data from Microsoft Excel
            6. 3.4.1.6. Importing data from Microsoft Access
            7. 3.4.1.7. Importing data from SQL Server 2000
        5. 3.5. Querying a MapPoint DataSet
          1. 3.5.1. Executing Location Queries Using MapPoint DataSet
          2. 3.5.2. Querying a Dataset for All Records
        6. 3.6. Working with Shapes
          1. 3.6.1. Drawing Shapes
            1. 3.6.1.1. Drawing a circle
            2. 3.6.1.2. Drawing a line
            3. 3.6.1.3. Drawing a polyline
            4. 3.6.1.4. Drawing a polygon
            5. 3.6.1.5. Accessing shape vertices
            6. 3.6.1.6. Drawing a text box
          2. 3.6.2. Altering Shape Appearance
            1. 3.6.2.1. Altering line width
            2. 3.6.2.2. Changing the fill color
            3. 3.6.2.3. Simulating translucency
            4. 3.6.2.4. Toggling shape visibility
          3. 3.6.3. Querying Shapes
          4. 3.6.4. Working with Drivetime Zones
        7. 3.7. Working with Territories
          1. 3.7.1. Determining a Location's Territory
        8. 3.8. Where Are We?
      3. 4. Advanced MapPoint 2004 Programming
        1. 4.1. Interfacing MapPoint 2004 with a GPS Device
          1. 4.1.1. GPS Basics
          2. 4.1.2. Understanding NMEA GPS Sentences
          3. 4.1.3. Parsing NMEA Sentences
          4. 4.1.4. Fields in the Fixed Data Sentence
          5. 4.1.5. Fields in the Position and Time Sentence
          6. 4.1.6. Converting NMEA Values
          7. 4.1.7. Converting Latitude and Longitude Information
          8. 4.1.8. Converting the Speed Information
          9. 4.1.9. Converting the Bearing Information
          10. 4.1.10. Converting the UTC Time Information
          11. 4.1.11. Communicating with a GPS device
          12. 4.1.12. Event-Based Architecture for Reading GPS Sentences
          13. 4.1.13. How to Use the Sample API in Your Applications
          14. 4.1.14. Displaying GPS Sentences Using MapPoint 2004
          15. 4.1.15. Centering the Map on the Current Location
        2. 4.2. Integrating Your Applications with MapPoint 2004
          1. 4.2.1. Developing the Add-In
          2. 4.2.2. Invoking Add-In Methods from an External Application
        3. 4.3. Performance Considerations
        4. 4.4. Where Are We?
    7. II. MapPoint Web Service
      1. 5. Programming MapPoint Web Service
        1. 5.1. How Does MapPoint Web Service Work?
        2. 5.2. Getting Started with MapPoint Web Service
          1. 5.2.1. Requesting MapPoint Web Service Credentials
          2. 5.2.2. Accessing the MapPoint Web Service APIs
          3. 5.2.3. Accessing the Customer Services Site
        3. 5.3. Preparing Your Development Environment
          1. 5.3.1. Adding a Web Reference
            1. 5.3.1.1. Static versus dynamic service URL
            2. 5.3.1.2. Storing your credentials securely
            3. 5.3.1.3. Preauthenticate requests for performance gains
        4. 5.4. Understanding MapPoint Web Service Object Model
          1. 5.4.1. Common Service
          2. 5.4.2. Find Service
          3. 5.4.3. Render Service
          4. 5.4.4. Route Service
          5. 5.4.5. MapPoint Web Service Data Sources
            1. 5.4.5.1. MapPoint data sources
            2. 5.4.5.2. Customer data sources
            3. 5.4.5.3. MapPoint Web Service data source capabilities
            4. 5.4.5.4. Language support in data sources
        5. 5.5. Where Are We?
      2. 6. MapPoint Web Service Find APIs
        1. 6.1. Understanding Find APIs
          1. 6.1.1. The Anatomy of Find Methods
        2. 6.2. Understanding Entities and Entity Relationships
          1. 6.2.1. Data Sources and Entity Types
            1. 6.2.1.1. Getting all supported entity types within a data source
        3. 6.3. Data Sources and Countries/Regions
          1. 6.3.1. Countries/Regions and Their Entity IDs
          2. 6.3.2. Querying for Geographic Extent for a Data Source
          3. 6.3.3. Programmatically Mapping a Country/Region to a Data Source
        4. 6.4. Working with Find Methods
          1. 6.4.1. Finding Places
            1. 6.4.1.1. Finding more default matches
            2. 6.4.1.2. Returning more find results
            3. 6.4.1.3. Selectively finding entity types
            4. 6.4.1.4. Limiting search to a geographic area
            5. 6.4.1.5. Finding geographic entities with no input place name
          2. 6.4.2. Finding Addresses
          3. 6.4.3. Finding Points of Interest Around a Location
            1. 6.4.3.1. Customer data sources—displaying your data
          4. 6.4.4. Finding Points of Interest Along a Route
          5. 6.4.5. Finding Custom Entity Types
            1. 6.4.5.1. Find entity by identity
            2. 6.4.5.2. Finding entity by properties
          6. 6.4.6. Finding Polygons
          7. 6.4.7. Getting Entities from Latitude/Longitude
          8. 6.4.8. Parsing Addresses
        5. 6.5. Asynchronous Programming with Find Service
          1. 6.5.1. Asynchronous Programming for Windows Applications
          2. 6.5.2. Asynchronous Programming for Web Applications
            1. 6.5.2.1. AJAX-Enabling Your Web Applications
            2. 6.5.2.2. Implementing MapPoint Lookup AJAX Application
        6. 6.6. Optimizing Find Call Performance
          1. 6.6.1. Optimizing the SOAP Response Size
          2. 6.6.2. Applying Proper Metadata for Faster Searches
          3. 6.6.3. Use Asynchronous Programming Patterns
        7. 6.7. Globalizing Find
        8. 6.8. Where Are We?
      3. 7. MapPoint Web Service Route APIs
        1. 7.1. Understanding Route APIs
          1. 7.1.1. Anatomy of a Route
          2. 7.1.2. Representing a Route Programmatically
        2. 7.2. Calculating a Route
          1. 7.2.1. Calculating a Route Using the CalculateSimpleRoute Method
          2. 7.2.2. Calculating a Route Using the CalculateRoute Method
            1. 7.2.2.1. Controlling the driving times
            2. 7.2.2.2. Setting default distance units
            3. 7.2.2.3. Setting the default culture
        3. 7.3. Displaying Details of a Route
          1. 7.3.1. Displaying the Route Summary
          2. 7.3.2. Displaying Route Details
        4. 7.4. Where Are We?
      4. 8. MapPoint Web Service Render APIs
        1. 8.1. Understanding Render APIs
          1. 8.1.1. Introduction to Views
            1. 8.1.1.1. View by bounding locations
            2. 8.1.1.2. View by height and width
            3. 8.1.1.3. View by scale
            4. 8.1.1.4. View by bounding rectangle
          2. 8.1.2. Understanding Map Styles
          3. 8.1.3. Anatomy of Render APIs
          4. 8.1.4. Rendering for Windows Versus Rendering for the Web
        2. 8.2. Rendering Maps
          1. 8.2.1. Rendering Places and Addresses
          2. 8.2.2. Rendering Pushpins
            1. 8.2.2.1. Rendering points of interest
            2. 8.2.2.2. Avoiding icon collision
            3. 8.2.2.3. Suppressing standard entity types
            4. 8.2.2.4. Converting pushpins to pixel coordinates
          3. 8.2.3. Rendering Routes
          4. 8.2.4. Rendering LineDrive Maps
          5. 8.2.5. Rendering Polygons
        3. 8.3. Map Interaction
          1. 8.3.1. Programming Map Zoom
          2. 8.3.2. Programming Map Pan
        4. 8.4. Asynchronous Programming
          1. 8.4.1. Asynchronous Programming for Windows Applications
          2. 8.4.2. Asynchronous Programming for Web Applications
            1. 8.4.2.1. AJAX-Enabling Your Web Applications
        5. 8.5. Where Are We?
    8. III. MapPoint Location Server
      1. 9. Programming Microsoft Location Server
        1. 9.1. Microsoft Location Server Terminology
        2. 9.2. How Does Location Server Work?
        3. 9.3. Microsoft Location Server Architecture
          1. 9.3.1. Microsoft Location Server Web Service
          2. 9.3.2. Microsoft Location Server Database
          3. 9.3.3. Microsoft Location Server Providers
        4. 9.4. Installing the Location Server
          1. 9.4.1. Installation Overview
        5. 9.5. Accessing the Location Service APIs
        6. 9.6. Accessing the Location Server APIs
        7. 9.7. Microsoft Location Server Supported Providers
        8. 9.8. Where Are We?
      2. 10. Programming with Location Server APIs
        1. 10.1. Programming with Location Server Web Service
          1. 10.1.1. Anatomy of Location Web Service APIs
          2. 10.1.2. Finding a Real-Time Location
          3. 10.1.3. Adding and Removing Contacts
            1. 10.1.3.1. If lookup is based on domain alias
            2. 10.1.3.2. If lookup is based on display name
            3. 10.1.3.3. If lookup is based on first name and last name
            4. 10.1.3.4. If lookup is based on phone number
            5. 10.1.3.5. If lookup is based on email address
          4. 10.1.4. Programming Privacy Settings
            1. 10.1.4.1. Managing contact privacy settings
            2. 10.1.4.2. Going into stealth mode—becoming invisible to all contacts
          5. 10.1.5. Finding Nearby Points of Interest
        2. 10.2. Programming with the Location Server Management API
          1. 10.2.1. Anatomy of Location Server Management APIs
          2. 10.2.2. Programming User Management
            1. 10.2.2.1. Adding users
            2. 10.2.2.2. Managing provisioned users
          3. 10.2.3. Programming Privacy Management
          4. 10.2.4. Programming Contact Management
          5. 10.2.5. Programming Find Nearby Category Management
        3. 10.3. Comparing Location Server API to Location Web Service API
        4. 10.4. Where Are We?
    9. IV. MSN Virtual Earth
      1. 11. Programming with Virtual Earth
        1. 11.1. Anatomy of Virtual Earth
        2. 11.2. Programming with MapControl.js
          1. 11.2.1. Map Control Basics
            1. 11.2.1.1. Changing the map style
            2. 11.2.1.2. Trapping the Virtual Earth Map Control events
          2. 11.2.2. Map Interaction Using Map Control
            1. 11.2.2.1. Panning the map
            2. 11.2.2.2. Zooming the map
          3. 11.2.3. Displaying Your Data on Maps
            1. 11.2.3.1. Adding a pushpin
            2. 11.2.3.2. Removing pushpins
            3. 11.2.3.3. Adding pushpins from RSS feed
        3. 11.3. Where Are We?
      2. A. Managing Your Data on MapPoint's Customer Services Site
        1. A.1. Using the MapPoint Customer Services Site
        2. A.2. Using Customer Data Web Service
          1. A.2.1. A Look at Customer Data Service APIs
            1. A.2.1.1. Uploading data using Customer Data Service
              1. A.2.1.1.1. Create a new upload job
              2. A.2.1.1.2. Upload your data
              3. A.2.1.1.3. Submit your data for processing
            2. A.2.1.2. Polling for an upload job status
            3. A.2.1.3. Downloading data using Customer Data Service
              1. A.2.1.3.1. Create a new download job
              2. A.2.1.3.2. Poll for the status of the job
              3. A.2.1.3.3. Download the data file and save it to your hard drive
      3. B. Working with Polygons
        1. B.1. What Is a Polygon?
        2. B.2. Polygon Relationships
        3. B.3. Rules for Preparing Polygon Data
        4. B.4. Polygon Data Schema Document
        5. B.5. Polygon Data Sample Document
      4. C. Implementing Spatial Search Using SQL Server
        1. C.1. Understanding Proximity Search
        2. C.2. Step 1: Create a Table to Store Your Business Location Data
        3. C.3. Step 2: Calculate Axis Values for the BusinessEntities Table
        4. C.4. Step 3: Create the FindNearby Stored Procedure
        5. C.5. Step 4: Using Your Find Nearby Stored Procedure Using C#
    10. D. Maps
    11. About the Author
    12. Colophon
    13. SPECIAL OFFER: Upgrade this ebook with O’Reilly