I couldn't think of a good way to break these apart, so I developed both imagery metadata (date of photography / imagery acquisition) and reverse geocoding (converting coordinates to the nearest address) together. Actually, I can think of many ways to get the reverse geocoding working without the imagery metadata - I did so in my "Getting Addresses Using Aerial Photos" post, but with the introduction of imagery metadata in our latest release, that is, getting some date information about when the ortho photography (not Bird's Eye) was captured I had to make something cool. So here it is. I need a place to host my ASP .Net applications to show them off. I'm frustrated. When I figure out what's wrong with my Win ISP account, I'll post them - I promise.


The application I wrote allows you to right-click anywhere on the map and (with the aerial map style) you can get the date photography/imagery was captured (as a range), the latitude and longitude coordinates of the pixel clicked, and subsequently the geocodes reversed to an address including the precision type - either interpolated or rooftop.

image A couple things you should know. (1) The imagery metadata method will only work if you have a valid production token - staging tokens will not work. (2) In order to have production access you must have a licensed version of Virtual Earth - send mail to the Virtual Earth Licensing Team to get a license. This means there are now 3 methods that only work if you're licensed to use Virtual Earth and NOT part of the free API (traffic flow data and exposed route geometry, being the other two).

With that in mind, let's do this. I have 3 files, but I'm going to show you 2. The third file is Authentication.cs which gets my token and you can read all about in my Authentication and Tokens with Virtual Earth post. The other two files are Metadata.aspx (for the UI) and Metadata.aspx.cs (as the code behind - filled with magic).


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MetaData.aspx.cs" Inherits="MetaData" %>



      CP's Meta Data & Reverse Geocoding Page






using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using VEWSStaging;

public partial class MetaData : System.Web.UI.Page
    public string strClientToken;
    protected void Page_Load(object sender, EventArgs e)
        strClientToken = Authentication.Authenticate(Page.Request.UserHostA ddress);


As you can see, most of the code happens in the ASPX file, as opposed to the ASPX.CS file because we're using the AJAX control. My recent VEWS posts are the flip of that allowing .Net developers to leverage their knowledge and still get maps and aerial photos for their applications without worrying about JavaScript. Or, you could be cool like me and do both! Someone called me a narcissist today!!! WTH??

The code is fairly well documented, but feel free to ping me with questions. For those who want to know, yes the imagery data and reverse geocoding are both available in the Virtual Earth Web Service, as well (production only, for metadata).


Click here to view the article.