Sunday, February 6, 2011

Django - Internationalisation and Google Maps api v3

Programmer Question

Hi, all



I have a Django app and have integrated some Google maps via the v3 api. After a week of discovery and playing around everything was working fine, until...



I changed the language on my app by clicking on a flag on a form that POSTS the action to /i18n/setlang/, which is what Django uses to change the language. Now the new language is showing up, but the maps aren't. In the Chrome debugger it's giving the following error:



Failed to load resource: the server responded with a status of 400 (Bad Request)

StaticMapService.GetMapImage


The following is the Chrome debugger header content for the error:



1.
Request URL:
http://maps.googleapis.com/maps/api/js/StaticMapService.GetMapImage?1m2&1iNaN&2iNaN&2e2&3u8&4m2&1uNaN&2uNaN&5m3&1e3&2b1&5sen-US&token=128748
2.
Request Method:
GET
3.
Status Code:
[400 Bad Request]
400 Bad Request
4. Request Headers
1.
Referer:
http://127.0.0.1:8000/uns/uns_cities_form/Mu%C4%9Fla/
2.
User-Agent:
Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3
5. Query String Parameters
1.
1m2:
2.
1iNaN:
3.
2iNaN:
4.
2e2:
5.
3u8:
6.
4m2:
7.
1uNaN:
8.
2uNaN:
9.
5m3:
10.
1e3:
11.
2b1:
12.
5sen-US:
13.
token:
128748
6. Response Headers
1.
Content-Length:
1350
2.
Content-Type:
text/html; charset=UTF-8
3.
Date:
Sun, 06 Feb 2011 20:29:59 GMT
4.
Server:
staticmap
5.
X-XSS-Protection:
1; mode=block


If I set the language back to English all works fine again...



Ok, so there is nothing to do with any translation whilst loading the map, but I'm figuring that Django has changed something or other which is disrupting the Http request, although to be honest I have no idea what is going on. The following is the options and the call to the map



//Map Options
myOptions =
{
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.HYBRID,
streetViewControl: false,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
},
}

//Create the map
map = new google.maps.Map(elem,myOptions);


Has anyone come across this, or can anyone throw some light on what might be happening?



enter code here


Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails