airbnb/AirMapView

Marker positions are incorrect in web map when device language is changed

geofffalk opened this issue · 4 comments

With the sample app installed on a UK based device, Nexus 6 running Lollipop

  1. Change device language to Spanish / German etc
  2. Select 'Use Google Web Map' or 'Use MapBox Map'
  3. RESULT: the markers are incorrectly placed in a horizontal line across globe

If you change the language to certain Asian ones - Chinese, Thai for example, the markers are correctly placed.

Found fix.
The issue is that the String.format function is translating the commas in the url strings, resulting in corrupted javascript method calls.
To fix the issue, the locale needs to be explicitly set to US in each String.format e.g.
webView.loadUrl(String.format(Locale.US, "javascript:addMarkerWithId(%1$f, %2$f, %3$d, '%4$s', '%5$s');", latLng.latitude, latLng.longitude, marker.getId(), marker.getTitle(), marker.getSnippet()))

I see the issue is replicable on the live AirBnB application too.

@geofffalk thank you for reporting and for the fix!