Search code examples
ember.jsintellij-ideaopenlayers-3amd

import openlayers3 in ember.js


I am starting up an ember.js app aimed at drawing and displaying maps.

I am using ember.js v1.11.0 and ol3 v3.4.0

I managed to install ol3 via bower and import it using Brocfile.js:

app.import('bower_components/ol3/build/ol.js');
app.import('bower_components/ol3/css/ol.css');

I can use it as well without problem in my views, etc. What I would like if possible is to get rid of the server errors:

views/map.js: line 6, col 22, 'ol' is not defined.
views/map.js: line 7, col 19, 'ol' is not defined.
views/map.js: line 10, col 21, 'ol' is not defined.
views/map.js: line 11, col 19, 'ol' is not defined.
views/map.js: line 14, col 19, 'ol' is not defined.
views/map.js: line 17, col 17, 'ol' is not defined.

And if possible get autocompletion in my Intellij IDEA (make it recognise the ol library)

If somebody could give me a hand, that owuld be much apreciated.


Solution

  • add ol to your .jshintrc file. in the predef array:

    "predef": [
      "document",
      "window",
      "-Promise",
      "ol"
    ]
    ....
    

    And for the intellij-idea you should be able to get your answer from the docs here: https://www.jetbrains.com/idea/help/configuring-javascript-libraries.html