AI prompts
base on React components and hooks for the Google Maps JavaScript API # React Components for the Google Maps JavaScript API
[![MIT License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/visgl/react-google-maps/tree/main/LICENSE)
This is a TypeScript / JavaScript library to integrate the Maps JavaScript API
into your React application.
It comes with a collection of React components to create maps, markers and
infowindows, and a set of hooks to use some of the Maps JavaScript API
[Services][gmp-services] and [Libraries][gmp-libraries].
## Installation
This library is available on npm as [`@vis.gl/react-google-maps`][npm-package].
```sh
npm install @vis.gl/react-google-maps
```
or
```sh
yarn add @vis.gl/react-google-maps
```
_(PowerShell users: since `@` has a special meaning in PowerShell, the
package name has to be quoted)_
## Usage
Import the [`APIProvider`][api-provider] and wrap it around all components that should have
access to the Maps JavaScript API.
Any component within the context of the `APIProvider` can use the hooks and
components provided by this library.
To render a simple map, add a [`Map`][api-map] component inside the `APIProvider`.
Within the `Map` component, you can then add further components like
[`Marker`][api-marker], [`AdvancedMarker`][api-adv-marker], or
[`InfoWindow`][api-infowindow] to render content on the map.
For more advanced use-cases you can even add your own components to the map
that make use of `google.maps.OverlayView` or `google.maps.WebGlOverlayView`.
```tsx
import {AdvancedMarker, APIProvider, Map} from '@vis.gl/react-google-maps';
function App() {
const position = {lat: 53.54992, lng: 10.00678};
return (
<APIProvider apiKey={'YOUR API KEY HERE'}>
<Map defaultCenter={position} defaultZoom={10} mapId="DEMO_MAP_ID">
<AdvancedMarker position={position} />
</Map>
</APIProvider>
);
}
export default App;
```
Please see our [documentation][docs] or [examples][] for more in-depth information
about this library.
### Using other libraries of the Maps JavaScript API
Besides rendering maps, the Maps JavaScript API has a lot of
[additional libraries][gmp-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
the [`useMapsLibrary()`][api-use-lib] hook to handle dynamic loading of
additional libraries.
For example, if you just want to use the `google.maps.geocoding.Geocoder` class in
a component and you don't even need a map, it can be implemented like this:
```tsx
import {useMap, useMapsLibrary} from '@vis.gl/react-google-maps';
const MyComponent = () => {
// useMapsLibrary loads the geocoding library, it might initially return `null`
// if the library hasn't been loaded. Once loaded, it will return the library
// object as it would be returned by `await google.maps.importLibrary()`
const geocodingLib = useMapsLibrary('geocoding');
const geocoder = useMemo(
() => geocodingLib && new geocodingLib.Geocoder(),
[geocodingLib]
);
useEffect(() => {
if (!geocoder) return;
// now you can use `geocoder.geocode(...)` here
}, [geocoder]);
return <></>;
};
const App = () => {
return (
<APIProvider apiKey={'YOUR API KEY HERE'}>
<MyComponent />
</APIProvider>
);
};
```
## Examples
Explore our [examples directory on GitHub](./examples) or the
[examples on our website][examples] for full implementation examples.
## Supported Browsers
Being a library built around the Google Maps JavaScript API, we follow the
same browser-support policy as the Google Maps Team,
[available here][gmp-browsersupport].
Generally, the last two versions of the major browsers are officially supported.
It is not unlikely that browsers even far outside the given
range will still work. We try our best to support as many browsers and
versions as reasonably possible, but we won't actively investigate issues
related to outdated browser versions.
However, if you can suggest small changes that could be made to even
increase that range, we will be happy to include them, as long as they don't
negatively affect the supported browsers.
## Terms of Service
`@vis.gl/react-google-maps` uses Google Maps Platform services. Use of Google
Maps Platform services through this library is subject to the
[Google Maps Platform Terms of Service][gmp-tos].
This library is not a Google Maps Platform Core Service.
Therefore, the Google Maps Platform Terms of Service (e.g., Technical
Support Services, Service Level Agreements, and Deprecation Policy)
do not apply to this library.
## Help and Support
This library is offered via an open source license. It is not governed by the
Google Maps Platform [Technical Support Services Guidelines][gmp-tssg],
the [SLA][gmp-sla], or the [Deprecation Policy][gmp-dp] (however, any Google
Maps Platform services used by this library remain subject to the Google Maps
Platform Terms of Service).
If you find a bug or have a feature request, please [file an issue][rgm-issues]
on GitHub. If you would like to get answers to technical questions from
other Google Maps Platform developers, feel free to open a thread in the
[discussions section on GitHub][rgm-discuss] or ask a question through one of
our [developer community channels][gmp-community].
If you'd like to contribute, please check the [Contributing guide][rgm-contrib].
You can also discuss this library on [our Discord server][gmp-discord].
[api-provider]: https://visgl.github.io/react-google-maps/docs/api-reference/components/api-provider
[api-map]: https://visgl.github.io/react-google-maps/docs/api-reference/components/map
[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/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
[gmp-libraries]: https://developers.google.com/maps/documentation/javascript/libraries
[npm-package]: https://www.npmjs.com/package/@vis.gl/react-google-maps
[gmp-tos]: https://cloud.google.com/maps-platform/terms
[gmp-tssg]: https://cloud.google.com/maps-platform/terms/tssg
[gmp-sla]: https://cloud.google.com/maps-platform/terms/sla
[gmp-dp]: https://cloud.google.com/maps-platform/terms/other/deprecation-policy
[rgm-issues]: https://github.com/visgl/react-google-maps/issues
[rgm-discuss]: https://github.com/visgl/react-google-maps/discussions
[rgm-contrib]: https://visgl.github.io/react-google-maps/docs/contributing
[gmp-community]: https://developers.google.com/maps/developer-community
[gmp-discord]: https://discord.gg/f4hvx8Rp2q
[gmp-browsersupport]: https://developers.google.com/maps/documentation/javascript/browsersupport
", Assign "at most 3 tags" to the expected json: {"id":"10241","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"