Skip to content

Instantly share code, notes, and snippets.

@printercu
Last active August 15, 2016 17:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save printercu/c4a02b8972ad76b6331b51b98c4b87a5 to your computer and use it in GitHub Desktop.
Save printercu/c4a02b8972ad76b6331b51b98c4b87a5 to your computer and use it in GitHub Desktop.
Keep MarkerClusterer working after Google shut down svn-repos

First we’ll configure Rails, assuming you already have a copy of google-maps-utility-library-v3 in your repo. If you don’t have it yet, there are instructions in the bottom.

Most likely, you already have added utility folder to the assets pipeline:

# config/initializer/assets.rb
Rails.application.config.assets.paths += %W(
 #{Rails.root}/vendor/assets/google-maps-utility-library-v3
)

Tell sprockets you want it to compile images too:

# config/initializer/assets.rb
Rails.application.config.assets.precompile += %w(
 markerclustererplus/images/*.png
)

Configure MarkerClusterer to use self-hosted images.

#= require markerclustererplus/src/markerclusterer_packed.js
#= require infobox/src/infobox_packed.js
# ... require anything you want

MarkerClusterer.IMAGE_PATH = '/assets/markerclustererplus/images/m'

That’s all. Continue reading if you don’t had a copy of utility library yet.

I use git submodules to add google-maps-utility-library-v3 to the repo:

git submodule add \
  https://github.com/printercu/google-maps-utility-library-v3-read-only.git \
  vendor/assets/google-maps-utility-library-v3

Don’t forget to configure your deployment. After checkout run:

git submodule init
git submodule sync
git submodule update — init

And you’re ready for deploy.

You can try to find bower package or just check-in all the files to your repo if you don’t want to deal with submodules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment