tomchentw / react-google-maps

React.js Google Maps integration component
https://tomchentw.github.io/react-google-maps/
MIT License
4.63k stars 938 forks source link

Markerclusterer: setting the iconPath property has no effect #846

Open gergely-ujvari opened 6 years ago

gergely-ujvari commented 6 years ago

Setting the iconPath property for the MarkerClusterer Component has no effect. Markerclustererplus still gets the icons from the default url.

This is because how the underlying library works:

A possible workaround is to reset the style list manually, something like this. Inside src/components/addons/MarkerClusterer.jsx:

  imagePath(instance, imagePath) {
    instance.setImagePath(imagePath)
    instance.styles_ = []
    instance.setupStyles_()
  },

instead of

  imagePath(instance, imagePath) {
    instance.setImagePath(imagePath)
  },
entr commented 5 years ago

Very annoying indeed. If you need it changed just once override the IMAGE_PATH property of what the marker-clusterer-plus module exports.

import MarkerClustererPlus from 'marker-clusterer-plus'
import { MarkerClusterer } from 'react-google-maps/lib/components/addons/MarkerClusterer'

MarkerClustererPlus.IMAGE_PATH = '/mapclusterer/m'

// your important stuff as usual

This worked for me