3
Vote

Maps don't load when globalization culture uses 'comma' as decimal separator

description

If you set the globalization culture of the web application to one which uses 'comma' as a decimal separator, the JS code gets rendered incorrectly for numeric values.
 
To reproduce the error, add <globalization culture="es-AR" /> to the web.config and open the home page of the InteractiveSDKwebsite.
 
I believe the problem can be solved by updating the Render method of the JsonObjectBuilder class.
 
Thanks for the great app. Hope this helps.

comments

bckspc wrote Jan 24, 2010 at 1:13 PM

Same problem here. I'm in Portugal and JSON also defaults decimal to comma.

I realized that for me, the problem only occured in lat and long variables so I made a temporary fix to use the maps using ToString with InvariantCulture.

On the file Map.cs, on the function RenderObjectInitializer I made:

"
if (this.CenterLatitude.HasValue && this.CenterLongitude.HasValue) {
json.Append("lat", this.CenterLatitude.Value.ToString(CultureInfo.InvariantCulture)).Append("lng", this.CenterLongitude.Value.ToString(CultureInfo.InvariantCulture));
}

wrote Jan 24, 2010 at 1:13 PM

bckspc wrote Jan 24, 2010 at 9:08 PM

Fix update: I've realized that I only corrected the problem for the center of the map. To correct the culture problem also to the pushpins you have to:

In file LatLng.cs change the function:
    internal virtual JsonObjectBuilder ToJsonObjectBuilder()
    {
        var json = new JsonObjectBuilder();
        json.Append("lat", this.Latitude.ToString(System.Globalization.CultureInfo.InvariantCulture));
        json.Append("lng", this.Longitude.ToString(System.Globalization.CultureInfo.InvariantCulture));
        return json;
    }

wrote May 24, 2010 at 6:40 PM

wrote Feb 14, 2013 at 2:52 AM

NicoMijoch wrote Jun 2, 2013 at 7:36 PM

Also you need to correct the Shapes pages.

The Polygon.cs needs to fix the follwing code:
  if (this.LineOpacity.HasValue)
            {
                json.Append("lineopacity", this.LineOpacity.Value.ToString(System.Globalization.CultureInfo.InvariantCulture));
            }
// Some funtions below

if (this.FillOpacity.HasValue)
            {
                json.Append("fillopacity", this.FillOpacity.Value.ToString(System.Globalization.CultureInfo.InvariantCulture));
            }
The Polyline.cs needs to fix the follwing code:
 if (this.LineOpacity.HasValue)
            {
                json.Append("lineopacity", this.LineOpacity.Value.ToString(System.Globalization.CultureInfo.InvariantCulture));
            }