Earlier this week I was thinking, wouldn't it be cool if the MapQuest .NET API would allow me to program all my logic in C# (or VB.NET) and then instead of having it generate a bitmap, have it generate just the URL of a map? The URL can be used in web applications or I can embed the url in an image tag which I send as an email. A whole new world of possibilities opens up. Guess what? Generating an URL for a MapQuest map is part of the API today!

In a previous blog post I described how to use the Exec object to create a bitmap of a map:

sbyte[] imageBytes = Exec.GetMapImageDirect( session );
byte[] bytes = (byte[]) (Array) imageBytes;

MemoryStream stream = new MemoryStream( bytes );
Bitmap bitmap = new Bitmap( stream );

Using the same Exec object, just use the GetMapDirectURLEx method to build an URL to the same image.

string url = Exec.GetMapDirectURLEx( session, new MQClientInterface.DisplayState() );
Just assign the URL to an the ImageURL property of an ASP.NET Image control and the map will be displayed.
imgMap.ImageUrl = url;   // imgMap is an Image control

I ran my code on the development environment and as such I get back a reference to the MapQuest dev box:


As you can see my route from work to home is not very long :-)