0

I have created a JS template with this code to output GeoJSON for our Google Maps;

{
  "type": "FeatureCollection",
  "features": [
    {exp:channel:entries
        channel="places"
    }
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          {longitude},
          {latitude}
        ]
      },
      "properties": {
        "name": "{title}",
        "url": "{url_title}",
        "address": "{addressline1}, {if addressline2}{addressline2}, {/if}{city}, {postalcode}",
        "icon": "/static/markers/place.png"
      }
    },{/exp:channel:entries}
  ]
}

However, some of the titles have an apostrophe or accented characters, which are being included in the GeoJSON like so;

Bar ‘67
Café and Bar

I was wondering if anyone knows how I can correct this?

Thanks

  • just for sure - is your JS file output with utf-8 in header? "Content-Type:text/javascript; charset=UTF-8"? – Max Lazar Oct 8 '14 at 11:15
  • Hi Max, it doesn't appear to be. The template has been created with type JavaScript but in Developer Tools i'm seeing; Content-Type:text/javascript and no encoding. – doubleplusgood Oct 8 '14 at 13:41
  • so this is your answer - u need to add utf-8. If your server works with .htaccess - try to add line AddDefaultCharset UTF-8 – Max Lazar Oct 8 '14 at 18:18
1

As we discus in comments, its most probable that you have this issue because server is not return correct charset (utf-8) by default. You can try next:

for apache - add into .htaccess:

AddDefaultCharset utf-8

for nginx:

charset utf-8;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.