Skip to content

Instantly share code, notes, and snippets.

@colllin
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colllin/cdeb89aad87f5cac8104 to your computer and use it in GitHub Desktop.
Save colllin/cdeb89aad87f5cac8104 to your computer and use it in GitHub Desktop.
Reactive Leaflet Wrapper for Meteor (Readme-driven development)

This Meteor package wraps Leaflet in a reactive API.

The following methods have been added to the L.Map class:

isDragging()

returns true or false and is reactive.

getCenterState()

Treats the maps center lon/lat as a state of the map. Meaning that if you set the center, the new state will be that center, as opposed to calling getCenter() which would return the instantaneous (visible) position of the map, which might be transitioning between its previous center state and its new center state. Essentially, it detaches the model (which is pure data) from the view (which is a function of the previous data and the new data). It could be considered an alternative to using the map's moveend event, although the value will be updated at the time of the map's movestart event.

setCenterState()

This is really just an alias for map.setCenter(), and provides congruity for getCenterState().

The following methods on the L.Map class have been changed to be reactive:

getCenter()

This alleviates the need for the map's 'move' event.

getZoom()

This alleviates the need for the map's 'zoomend' event.

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