WP7 BingMapsDirectionsTask bug(s)

SneWs's picture

Microsoft and WP7 are still struggling with encodings other than en-US (US-ASCII). A great example of this is the BingMapsDirectionsTask found in the WP7 Mango API's.

Calling this task with a culture like Swedish where the decimal separator is a , (comma) character instead of a . (dot) character, will make it fail to parse latitude & longitude data. This is 2011, soon to be 2012, how can the WP7 team miss something so crucial and in my eyes, obvious use case.

But hey, that's not all, instead of using UTF-8 for the location data labels start and end, they seem to be using US-ASCII making input from other languages fail and look like it's 1998 once again. The obvious example of that is with Swedish characters Å, Ä and Ö (see screenshot).

Come on Microsoft, WP7 is a awesome device with really good API's. Missing obvious things like character encoding and globalization is just not acceptable in the year 2011, soon to be 2012.

After some searching of the web, I found a quick workaround that I implemented to fix the latitude & longitude bug. at Apeoholic.se
Please note that this workaround does NOT solve the character encoding issue for start and end labels
string realCulture = Thread.CurrentThread.CurrentCulture.Name;
	var directionsTask = new BingMapsDirectionsTask {
		Start = new LabeledMapLocation("", _currentGeoLocation),
		End = new LabeledMapLocation(_store.StreetAddress, new GeoCoordinate(_store.Latitude, _store.Longitude))

	// Switch to en-US culture before launching the task
	Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
catch (Exception error)
	Debug.WriteLine("Unable to start bing directions task");
	// Switch back to the culture we had before
	Thread.CurrentThread.CurrentCulture = new CultureInfo(realCulture); 

Happy WP7 hacking!