I’ve been having a reasonably productive time getting up to speed with ClojureScript for my Harrisburg city crime tracker. One difficult bit of trial-and-error I came across is successfully compiling the Google Maps API into my app with advanced optimizations set. The Google Closure compiler munges identifiers so you need an “externs” file so it knows which names correlate to what from your CLJS code.
Here’s what I have in my project.clj
:
The :externs
vector is a list of all the externs JS files (which are
then placed in the src/cljs
directory — actually I should put them
in a src/cljs/externs
directory for organization’s sake).
The contents of google_maps_api_v3.js
come from
https://code.google.com/p/closure-compiler/source/browse/contrib/externs/maps/google_maps_api_v3.js.
Then, you can use the Maps API from inside your CLJS via the normal JS interop methods:
For further examples, you can refer to the hbg-crime.org source.