Skip to content

Commit

Permalink
docs: kebap-case filenames in hooks docs
Browse files Browse the repository at this point in the history
  • Loading branch information
usefulthink committed Nov 1, 2023
1 parent d5088ac commit c2285de
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Explore our [examples directory on GitHub](./examples) or the
[api-marker]: https://visgl.github.io/react-google-maps/docs/api-reference/components/marker
[api-adv-marker]: https://visgl.github.io/react-google-maps/docs/api-reference/components/advanced-marker
[api-infowindow]: https://visgl.github.io/react-google-maps/docs/api-reference/components/info-window
[api-use-lib]: https://visgl.github.io/react-google-maps/docs/api-reference/hooks/useMapsLibrary
[api-use-lib]: https://visgl.github.io/react-google-maps/docs/api-reference/hooks/use-maps-library
[docs]: https://visgl.github.io/react-google-maps/docs/
[examples]: https://visgl.github.io/react-google-maps/examples
[gmp-services]: https://developers.google.com/maps/documentation/javascript#services
Expand Down
4 changes: 2 additions & 2 deletions docs/api-reference/components/api-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ map-instances, libraries and the loading-status.

The following hooks are built to work with the `APIProvider` Component:

- [`useApiIsLoaded()`](../hooks/useApiIsLoaded.md) and [`useApiLoadingState()`](../hooks/useApiLoadingStatus.md) to check the current loading state of the API.
- [`useMapsLibrary()`](../hooks/useMapsLibrary.md) to load additional [Maps Libraries][gmp-libs].
- [`useApiIsLoaded()`](../hooks/use-api-is-loaded.md) and [`useApiLoadingState()`](../hooks/use-api-loading-status.md) to check the current loading state of the API.
- [`useMapsLibrary()`](../hooks/use-maps-library.md) to load additional [Maps Libraries][gmp-libs].

## Source

Expand Down
4 changes: 2 additions & 2 deletions docs/api-reference/components/map.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ the original default inline style of the map.
The `initialBounds` property can receive bounds on the initial map load.

When multiple `Map` components are used, it is necessary to apply an id to each Map instance. The id can be used to reference the
Map instance when using the [`useMap` hook](../hooks/useMap.md).
Map instance when using the [`useMap` hook](../hooks/use-map.md).

```tsx
interface MapProps extends google.maps.MapOptions {
Expand All @@ -137,5 +137,5 @@ interface MapProps extends google.maps.MapOptions {

To see the Map on the screen, you must set `zoom` and `center` together, or `initialBounds` as options. These
options can also be set later via `map.setOptions(...)` when the Map instance is accessed via
the [useMap hook](../hooks/useMap.md). The props `viewport`, `viewState` and `initialViewState` are used
the [useMap hook](../hooks/use-map.md). The props `viewport`, `viewState` and `initialViewState` are used
for an integration with the [DeckGL React Component](https://deck.gl/docs/get-started/using-with-react) and the Map.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
47 changes: 35 additions & 12 deletions docs/interacting-with-the-google-maps-api.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
# Interacting with the Google Maps API

With the provided components you are able to declaratively create a [Google Map](./api-reference/components/map.md) or a map with [markers](./api-reference/components/marker.md) for example.

Besides that there are three main ways and concepts to interact with the Google Maps API on lower level with this library. You can use the provided hooks, the refs that are available for some components or use the [`useMapsLibrary`](./api-reference/hooks/useMapsLibrary.md) hook to tap into other libraries and services of the Google Maps API or craft your own custom hooks.
With the provided components, you are able to declaratively create a
[Google Map](./api-reference/components/map.md) or a map with
[markers](./api-reference/components/marker.md) for example.

Besides that, there are three main ways and concepts to interact
with the Google Maps API on lower level with this library.
You can use the provided hooks, the refs that are available for
some components or use the
[`useMapsLibrary`](./api-reference/hooks/use-maps-library.md) hook
to tap into other libraries and services of the Google Maps API or
craft your own custom hooks.

## Hooks

There are several hooks that provide additional functionality for the map or maps you create. The main one being the [`useMap`](./api-reference/hooks/useMap.md) hook. This hooks give you access to the underlying `google.maps.Map` instance. Every child component that is wrapped in the `<APIProvider>...</APIProvider>` component has access to the map instance via this hook.
There are several hooks that provide additional functionality for the
map or maps you create.
The main one being the [`useMap`](./api-reference/hooks/use-map.md) hook.
This hooks give you access to the underlying `google.maps.Map` instance.
Every child component wrapped in the `<APIProvider>...</APIProvider>`
component has access to the map instance via this hook.

```tsx
import React, {useEffect} from 'react';
Expand Down Expand Up @@ -35,15 +48,24 @@ const App = () => (

Other hooks provide access to different Google Maps API services:

- [useDirectionsService](./api-reference/hooks/useDirectionsService.md) for the [Directions Service](https://developers.google.com/maps/documentation/javascript/directions)
- [useStreetViewPanorama](./api-reference/hooks/useStreetViewPanorama.md) for the [Streetview Service](https://developers.google.com/maps/documentation/javascript/streetview)
- [useAutocomplete](./api-reference/hooks/useAutocomplete.md) for the [Places Widget](https://developers.google.com/maps/documentation/javascript/reference/places-widget)
- [useDirectionsService](./api-reference/hooks/use-directions-service.md)
for the [Directions Service](https://developers.google.com/maps/documentation/javascript/directions)
- [useStreetViewPanorama](./api-reference/hooks/use-streetview-panorama.md) for the [Streetview Service](https://developers.google.com/maps/documentation/javascript/streetview)
- [useAutocomplete](./api-reference/hooks/use-autocomplete.md) for the [Places Widget](https://developers.google.com/maps/documentation/javascript/reference/places-widget)

The [useMapsLibrary](./api-reference/hooks/useMapsLibrary.md) hook can be utilized to load other parts of the Google Maps API that are not loaded by default. For example the Places Service or the Geocoding Service. [Learn how to use this hook](#other-google-maps-api-libraries-and-services)
The [useMapsLibrary](./api-reference/hooks/use-maps-library.md) hook can be
utilized to load other parts of the Google Maps API that are not loaded by default.
For example, the Places Service or the Geocoding Service.
[Learn how to use this hook.](#other-google-maps-api-libraries-and-services)

## Refs

The `<Marker>` and the `<AdvancedMarker>` components accept a `ref` prop which provides access to the underlying `google.maps.Marker`/`google.maps.marker.AdvancedMarkerElement` instance. Here is an example of how to use the `useMarkerRef` hook to get access to a marker instance. The same concept applies for the `<AdvancedMarker>` (using the `useAdvancedMarkerRef` hook)
The `<Marker>` and the `<AdvancedMarker>` components accept a `ref` prop which
provides access to the underlying `google.maps.Marker` / `google.maps.marker.AdvancedMarkerElement`
instance.

Here is an example of how to use the `useMarkerRef` hook to get access to a marker instance.
The same concept applies for the `<AdvancedMarker>` (using the `useAdvancedMarkerRef` hook).

```tsx
import React from 'react';
Expand Down Expand Up @@ -80,9 +102,10 @@ export default App;
## Other Google Maps API libraries and services

The Maps JavaScript API has a lot of [additional libraries](https://developers.google.com/maps/documentation/javascript/libraries)
for things like geocoding, routing, the Places API, Street View, and a lot more. These libraries
are not loaded by default, which is why this module provides a hook
`useMapsLibrary()` to handle dynamic loading of those libraries.
for things like geocoding, routing, the Places API, Street View, and
a lot more. These libraries are not loaded by default, which is why this
module provides a hook [`useMapsLibrary()`](./api-reference/hooks/use-maps-library.md)
to handle dynamic loading of those libraries.

For example, if you want to write a component that needs to use the
`google.maps.places.PlacesService` class, you can implement it like this:
Expand Down
12 changes: 6 additions & 6 deletions docs/table-of-contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
"collapsed": true,

"items": [
"api-reference/hooks/useMap",
"api-reference/hooks/useApiIsLoaded",
"api-reference/hooks/useMapsLibrary",
"api-reference/hooks/useDirectionsService",
"api-reference/hooks/useStreetViewPanorama",
"api-reference/hooks/useAutocomplete"
"api-reference/hooks/use-map",
"api-reference/hooks/use-api-is-loaded",
"api-reference/hooks/use-maps-library",
"api-reference/hooks/use-directions-service",
"api-reference/hooks/use-streetview-panorama",
"api-reference/hooks/use-autocomplete"
]
}
]
Expand Down

0 comments on commit c2285de

Please sign in to comment.