Skip to content

MapPoint Web will shut down soon, what about my data?

If you have been working with Bing Maps technologies recently, you would know that MapPoint Web Services and MultiMap are being discontinued. Data that is currently stored on MapPoint or MultiMap will need to be migrated or it will be lost when they pull the plug.

All attempts at freezing time have failed thus far, which means you will have to update any automation systems that send data to these services. Although the API allows programmed uploads, there is no simple plugin to replace the old systems.

Enter the BSDS* tool. This is an open source tool built to geocode and upload your data to the new Bing Maps service. Download and use the tool as is, or modify it to suit your needs. It also handles some of the inconveniences and nuances of the Bing Maps service, such as adding the important header line, converting between different file formats, and washing your clothes (results may vary).

* Bing Spatial Data Services

WPF Bing Maps Control – Fashionably Late?

Just like this post introducing the WPF beta map control, it is better late than never.

It looks a bit like the Silverlight control, but I can’t complain because it looks pretty good. We’ll have to see what’s in store for the release version.

For now, take a look at what we have and start drooling over the possibilities. Although the majority of WPF apps are desktop apps, it still needs Internet access to retrieve map tiles. Go to http://www.bing.com/community/site_blogs/b/maps/archive/2011/08/23/announcing-the-bing-maps-wpf-control.aspx for the details, and most importantly, a download link!

If anyone is still holding their breath for the Java posts I mentioned, I advise you to take a breath. I still have to write it, but it is coming.

Bing Maps Geocoding REST Service, Java-ized.

As promised, I have put together a small sample Java application using the REST service to perform a simple geocode. When you download the code, you will see that it’s quite small, and it’s no mistake. There are no libraries to download and nothing to import other than the usual java packages.

Of course, there are always some things you can do to make things more neat. I chose to wrap the parameters into a class. You could choose not to use a class and just submit a URL directly. As always, this is a sample and may not follow best practices.

Also as always, you will need a Bing Maps key if you don’t already have one. Get one at http://www.bingmapsportal.com and sign in or register a Windows Live ID account.

Finally, here are the goodies: https://skydrive.live.com/redir?resid=C892201A27904576!352&authkey=!AAynYsNkDP3U-Z4

Go wild!

Update: I’ve moved the file to a new location that should be accessible. Sorry for the confusion.

Still using SOAP? Give Java and PHP a REST

The Bing Maps web services have been around for a while now and MapPoint web services are being shut down later this year. Many of the current users of MWS will be looking to switch their services to Bing. MWS uses SOAP. Bing Maps services offers SOAP so it’s obviously a natural choice.

A recurring topic that I’ve been seeing is how to set up Axis to use SOAP in Java and also how to set up a request in PHP. Axis is not exactly lightweight. Setting up a request in PHP can change depending on the SOAP module being used. So lately my question to the people asking me this is, why? Do you need to use SOAP?

Released late last year, Bing Maps now has a REST service. The functionality is slightly different but it’s not a new beast. The data you get is the same and with the exception of the Search service, the services are the same. Furthermore, the REST service allows users to save custom points if interest, a feature that was previously only available to MWS.

Over the next few posts, I will be showing how simple it is to use the REST services. If you have used SOAP on Java or PHP before you should quickly see how it makes more sense to be using REST instead if you have that option.

What makes you a developer?

I had a discussion with a colleague recently on interviewing new hires and testing their technical knowledge.

We often see that they claim to know several programming languages. Great! Everyone knows the same language, because they also took a course on it. So the question became how to determine what they really know.

Do we care that they learned C# syntax in school? Well yes, but no. As developers, we know the syntax too. That doesn’t make us good developers.

So I had a different idea. Programming is about logic. It’s about making the application do what it needs to do, and do it in any language we have (often determined by the client). To test their ability, I proposed to create several examples of code, pretty standard stuff really. Except it’s a language that’s never been seen before.

I’ll give an example in a totally bogus language, that also makes complete sense, like a pseudo-language. Any decent dev will be able to make sense of it, right?

AmbiguousMatchException and MapPoint Web Services Retirement

I recently had the privilege of running into this exception, which is as ambiguous as it sounds. As with any other exception, the first thing was to search for resolutions on the Internet. Most of the issues dealt with MVC and properties of extended classes.

The project I was updating is ASP.NET 1.1, and definitely not MVC. This exception isn’t even related to Bing Maps (though it happened to be a MapPoint project, which by the way is being retired November 18, 2011 if you haven’t already heard). The interesting thing is that the application worked in two environments, but not the third, which is where it mattered most.

In the end, the solution was simple. Keep in mind that it is a .NET 1.1 application. Normally when we deploy a VS2003 application MSI, it automatically chooses the application pool for us. Normally, this is fine, but this time the installer didn’t pick the right app pool. When I went to check on the application pool settings, I saw that it was running under a .NET 2.0 app pool! I then changed the virtual directory back to a sensible app pool running .NET 1.1 and everything started working again.

Bing Maps for PHP – Official code samples

For anyone that had been working in PHP and trying to get started with the Bing Maps services, you would have noticed that it was nearly impossible to find a code sample. While there is still no PHP specific reference, there are now a series of articles to help get started!

http://www.bing.com/community/blogs/maps/archive/2010/08/26/introducing-php-and-vb-net-sdks-for-bing-maps-platform.aspx

I had been meaning to write some samples for the new REST services. The articles provide step by step instructions and code samples to help get started. As always, security issues may not have been covered for the sake of simplicity. Check your server and applications for possible issues before releasing into a production environment.

Getting driving directions that avoid highways

Of the many feature requests I have heard, one is to retrieve driving directions that specifically avoid highways. This is useful in many situations so it is a very valid feature to have. Take for example in Ontario a driver with a G1 driver’s license cannot drive on a high-speed road (we call them highways in Ontario) without a registered driving instructor.

The route service allows a user to specify the mode of travel to consider when creating the route. In a recent update, walking directions were updated to allow a start and end point to be up to 200km away. While no person would normally walk 200km to a destination, this presents a special opportunity for us. On many highways, it is illegal for pedestrians and bicycles to enter. Using this, we can easily create a route that avoids highways. We can see this in action on the Bing Maps site as well.

WARNING: While this avoids highways, it also uses walking directions. This means that the path may take you off the road on pedestrian paths or down one way streets, for example. As always, use common sense when following directions.

Passing a ComplexType SOAP parameter in PHP

A colleague recently asked how the ConfidenceFilter could be used in a geocode call. In .NET this was simple – you only needed to set the value of the filter according to its enum value. There are no enums in PHP, so how would we do this?

In most cases, you would pass any parameters as arrays, or StdClass objects. This works fine for simple values like int or strings, but when you try to submit a ConfidenceFilter, for example, the geocode call gives you a server error. You might say it’s the server’s problem, but looking at the packet capture we can see that our filter isn’t being passed in.

Taking the ConfidenceFilter as an example, it is derived from the FilterBase class, so in essence it’s the same class. If you pass the ConfidenceFilter into the GeocodeOptions array, PHP creates a SOAP element <ConfidenceFilter>, which is wrong. If you pass in a <FilterBase>, the server rejects your request, so somehow you need to specify that the FilterBase tag actually contains a ConfidenceFilter-typed object.

$geocodeClient = new SoapClient($geocodeServiceWsdl, array('classmap' => array('ConfidenceFilter' => 'Confidence')));


// Confidence Filter
class Confidence {
public $MinimumConfidence;
}
// GeocodeOptions
$filter = new Confidence;
$filter->MinimumConfidence = 'High';
$geoOptions = array(
'Filters' => array('FilterBase' => $filter)
);

// GeocodeRequest "object"
$geocodeRequest = array(
'Credentials' => $credentials,
'Options' => $geoOptions,
'Query' => '1 Microsoft Way, Redmond, WA'
);

The above snippet will submit the proper ConfidenceFilter.

A few assumptions:

  • $geocodeServiceWsdl refers to the Geocode service URL.
  • Other options and credentials are set outside of this snippet.

The important part in the snippet is the classmap array in the SoapClient constructor. This allows us to define a class as a type, in the sense that PHP’s SOAP module will create the proper SOAP elements. Here, our classmap maps the type of ‘ConfidenceFilter’ to our class ‘Confidence’. You could easily give the class the same name as the type, but here we made them different for illustration. Now, when you pass in the ConfidenceFilter type, the FilterBase element will be given the xsd type of ConfidenceFilter, and the Bing Maps geocode service is now happy, and returns the filtered results you requested.

Consuming Bing Maps Web Services in PHP – Update

In the time since my last post with using PHP to access web services, there have been a few changes in the structure of Bing Maps. Most importantly, there is no longer a staging environment for developer access. Instead, all users access the same environment and access it with a Bing Maps API key. What does this mean? “Upgrading” to a production (or licensed) account is as simple as registering the account with Bing Maps licensing and switching out the key in a configuration file.

This is double-plus good for PHP because it saves the pain of retrieving the client token in a separate web service call. Just substitute the key for the client token in the Credentials array, with the key assigned as “ApplicationId”.

This makes sense, since there is no need to maintain two separate environments and two sets of servers, and developing applications in the same environment as it will be deployed to means there are no surprises when trying to switch the service references. Actually, there is no need to switch the references at all!

I thought I should also point out that the previous articles were meant as a starting point for current Bing Maps developers and are by no means following any best practices, nor are they properly documented with every step explained. If you are just starting out with Bing Maps, I strongly recommend looking at the .NET examples and articles before continuing in PHP. Those articles have API calls documented in MSDN and all of the techniques transfer to PHP in some way.