OpenLayers 5.3.0 and “SyntaxError: missing : in conditional expression”

Just a PSA for Openstreetmap Openlayers 5.3.0 API users.

The rawgit CDN ol.js file appears to contain a malformed ternary operation that causes browsers to not create the ol object, breaking map programs.

The Firefox web console says:

SyntaxError: missing : in conditional expression ol.js:1:34694

The solution is to switch CDN from rawgit to cdn.jsdelivr.net like this:

https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.3.1/css/ol.css

So definitely test your existing Openlayers code on a current version of Firefox.

There’s only a couple of searchable references starting May, 2020, so it’s something fairly new.

This entry was posted in Open Source. Bookmark the permalink.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.