Community of VE/MapPoint Users and Developers
This is a discussion on Geocoding with the Virtual Earth Web Service within the Virtual Earth Blogs forums, part of the Blogs category; For those of you who may want to get access to the 85 million unique rooftop or parcel centroid accurate ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Geocoding with the Virtual Earth Web Service For those of you who may want to get access to the 85 million unique rooftop or parcel centroid accurate points we've aggregated in the Virtual Earth Web Service (VEWS), I figured it was only fair that I post a little something to help move you along. Hopefully, this helps you get past a sticking point in your application development. Also, I did all of this on staging so everyone who has an account can do this. Okay, so, first things first, you need to authenticate - see my post Authentication and Tokens with Virtual Earth for authentication. You'll need a token to use any part of the VEWS and there's a good explanation on how to do that for VEWS in my other post (and information on getting a map) - Getting a Map with the Virtual Earth Web Service, but I'll copy the code to be nice. The application consists of 3 files - Authentication.cs (a class file for getting me a token); Geocoding.aspx (the UI file for adding web parts); and, Geocoding.aspx.cs (the code behind file where the magic happens). As for my code, it's only meant to get you up and running to understand architecture - it is not production code. You'll want error handling and try catches and all the good stuff - this is just the meat and potatoes. Authentication.cs using System; /// // Create the TokenSpecification object to pass to GetClientToken. // Use the Page object to retrieve the end-client’s IPAddress. // The maximum allowable token duration is 480 minutes (8 hours). // Now get a token from the Virtual Earth Platform Token service. Next, I'll need to set a reference to the geocoding service (WCF) - Website | Add Service Reference. I named my service "GeocodeService" which you can see has two methods - Geocode and ReverseGeocode. Next, we'll need to add UI elements to Geocoding.aspx. I added a Label (as a title), a Text box (to input addresses or places), a Button (to submit the data) and a Table (to store the results). When I'm done, Geocoding.aspx looks like this... Geocoding.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Geocoding.aspx.cs" Inherits="Geocoding" %> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> http://www.w3.org/1999/xhtml"> And now for the magic. We'll use these elements to make a service request to VEWS to submit the data in the text box and geocode the location. I'll take the entire response and break up each part so you can see most of what gets returned in the response. Make sure you add a reference to the GeocodeService we added above. Geocoding.aspx.cs using System; public partial class Geocoding : System.Web.UI.Page } The end results is a nice little parsing of some address information returned from VEWS: There isn't any difference in the geocoding results you get back between VEWS and the Virtual Earth AJAX control. Both now have rooftop and parcel centroid geocoding points totaling 85 million in the United States. Now, if I can just figure out what's up with the space between my text box and my table.... CP Click here to view the article. |
![]() |
| ||||
| Posted By | For | Type | Date | |
| The Magazine for MapPoint - MP2K Magazine | This thread | Refback | 09-30-2008 01:44 PM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Getting a Map with the Virtual Earth Web Service | VirtualEarth MSDN Blog | Virtual Earth Blogs | 0 | 09-26-2008 07:22 PM |
| Lancement de Virtual Earth Web Service et du Virtual Earth Map Control 6.2 | Virtual Earth Europe | Virtual Earth Blogs | 0 | 09-25-2008 04:22 AM |
| Announcing The Virtual Earth Web Service and Virtual Earth Map Control 6.2 | VirtualEarth MSDN Blog | Virtual Earth Blogs | 0 | 09-25-2008 01:21 AM |
| Geocoding with Virtual Earth | VirtualEarth MSDN Blog | Virtual Earth Blogs | 0 | 04-08-2008 03:10 AM |
| Virtual Earth Geocoding Accuracy Put to the Test | VE For Government | Virtual Earth Blogs | 1 | 01-15-2008 01:59 PM |