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

3
  • just for sure - is your JS file output with utf-8 in header? "Content-Type:text/javascript; charset=UTF-8"? Commented Oct 8, 2014 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. Commented Oct 8, 2014 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 Commented Oct 8, 2014 at 18:18

1 Answer 1

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;
2
  • Thanks for your help Max. I tried this but it still doesn't appear to work. I also tried alternatives from askapache.com/htaccess/setting-charset-in-htaccess.html. Commented Oct 9, 2014 at 8:16
  • Do you use https? .htaccess rules for remove index.php works for you? Commented Oct 9, 2014 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.