Content-Length: 32746 | pFad | https://visgl.github.io/react-google-maps/docs/api-reference/hooks/use-maps-library

useMapsLibrary Hook | React Google Maps
Skip to main content

useMapsLibrary Hook

React hook to get access to the different Maps JavaScript API libraries. This is essentially a react-version of the google.maps.importLibrary function.

const MyComponent = () => {
const map = useMap();
const placesLib = useMapsLibrary('places');

useEffect(() => {
if (!placesLib || !map) return;

const svc = new placesLib.PlacesService(map);
// ...
}, [placesLib, map]);

// ...
};

// Make sure you have wrapped the component tree with the APIProvider
const App = () => (
<APIProvider apiKey={/* ... */}>
{/* ... */}
<MyComponent />
</APIProvider>
);

Signature

useMapsLibrary(name: string): google.maps.XxxLibrary

Returns the library object as it is returned by google.maps.importLibrary.

Parameters

name: string (required)

The name of the library that should be loaded

Source

src/hooks/use-maps-library.ts









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://visgl.github.io/react-google-maps/docs/api-reference/hooks/use-maps-library

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy