[WP7] BingMapsDirectionsTask for non-US Bug


Hi all,

I recently found a « bug » in the BingMapsDirectionsTask for non-US users.

In theory, BingMapsDirectionsTask is very easy, just that :

BingMapsDirectionsTask task = new BingMapsDirectionsTask();

GeoCordinate geo = new GeoCordinate(47.6204,-122.3493);
LabeledMapLocation spaceNeedleLML = new LabeledMapLocation(yourlabel, geo);
task.End = spaceNeedleLML;

But the Windows Phone was allways searching the label and totally doesn’t care of the GeoCordinate.

So WTF?!


The bug is that WP7 parse with en-US Culture and not the device’s Culture…

The solution is :


string realCulture = Thread.CurrentThread.CurrentCulture.Name;

BingMapsDirectionsTask task = new BingMapsDirectionsTask();
LabeledMapLocation spaceNeedleLML = new LabeledMapLocation(your_label, geo);
task.End = spaceNeedleLML;
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

Thread.CurrentThread.CurrentCulture = new CultureInfo(realCulture);

First : We take the current Culture and save it.
Then : Change the current culture to « en-US ». The Show() will parse your GeoCordinate and will set your position with no problem \o/
Finally : Reset the current culture to the default one, yours.

And now we can fully work with the BingMapsDirectionsTask !

Other Bug

Meanwhile trying to solve the en-US bug, I found an other one. The label of BingMapsDirectionsTask is ASCII only.

We can’t use UTF8 (accented character) for the label it will do crap with it.

Exemple : « Méditerranée » (In French)

Microsoft, please think of non-US guys !

1 réflexion au sujet de “[WP7] BingMapsDirectionsTask for non-US Bug

%d blogueurs aiment cette page :