Hooks
React Maps Suite supports two hooks which allow you to extend the functionality of the map by directly accessing the underlying map libraries. The provider is rendered on the base <Maps />
component or the default export.
useMapCluster
Returns an object with googleCluster
(a @googlemaps/markerclusterer
object) and leafletCluster
(a L.MarkerClusterGroup
). This is used internally to cluster the markers.
useMap
Includes an object with:
type
: The provider which is being used (google | mapbox | leaflet).googleMap
: Agoogle.maps.Map
object, only if thetype
is google.mapBox
: Amapboxgl.Map
object, only if thetype
is mapbox.leaflet
: AL.Map
object, only if thetype
is leaflet.center
: The center of the map, regardless of the provider.zoom
: The zoom of the map, regardless of the provider.utils
: Helper functions that you can use regardless of the provider:animateTo
: animates the map towards a particular position.
animateToBounds
: animates the map towards specific bounds.
fitToPath
: fits the map to a set of bounds.
getElement
: returns the div that renders the map.
unproject
: returns the x, y coordinates for a given lat, lng.