Skip to content

Commit 76b4e67

Browse files
committed
Update instant-meilisearch readme
1 parent caf1e80 commit 76b4e67

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

packages/instant-meilisearch/README.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -747,29 +747,34 @@ The `geoSearch` widget displays search results on a Google Map. It lets you sear
747747
- ✅ templates: The templates to use for the widget.
748748
- ✅ cssClasses: The CSS classes to override.
749749

750-
[See our playground for a working exemple](./playgrounds/geo-javascript/src/app.js) and this section in our [contributing guide](./CONTRIBUTING.md#-geo-search-playground) to set up your `Meilisearch`.
750+
[See our playground for a working example](./playgrounds/geo-javascript/src/app.js) and this section in our [contributing guide](./CONTRIBUTING.md#-geo-search-playground) to set up your `Meilisearch`.
751751

752752
#### Requirements
753753

754-
The Geosearch widgey only works with a valid Google API key.
754+
The Geosearch widget only works with a valid Google API key.
755755

756-
In order to communicate your Google API key, your `instantSearch` widget should be surrounded by the following function:
756+
The example below uses the `@googlemaps/js-api-loader` package to load the Google Maps library before initializing `instantSearch`:
757757

758758
```js
759-
import injectScript from 'scriptjs'
760-
761-
injectScript(
762-
`https://maps.googleapis.com/maps/api/js?v=quarterly&key=${GOOGLE_API}`,
763-
() => {
764-
const search = instantsearch({
765-
indexName: 'geo',
766-
// ...
767-
})
768-
// ...
759+
import { setOptions, importLibrary } from '@googlemaps/js-api-loader'
760+
761+
const GOOGLE_MAP_API_KEY = 'YOUR_GOOGLE_MAPS_API_KEY'
762+
763+
setOptions({
764+
apiKey: GOOGLE_MAP_API_KEY,
765+
version: 'weekly',
766+
})
767+
768+
importLibrary('maps').then(() => {
769+
const search = instantsearch({
770+
indexName: 'geo',
771+
// ...
769772
})
773+
// ...
774+
})
770775
```
771776

772-
Replace `${GOOGLE_API}` with you google api key.
777+
Replace `YOUR_GOOGLE_MAPS_API_KEY` with your Google API key.
773778

774779
See [code example in the playground](./playgrounds/geo-javascript/src/app.js)
775780

0 commit comments

Comments
 (0)