![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@vis.gl/react-google-maps
Advanced tools
[!IMPORTANT] This project is still in its alpha phase.
When using it be aware that things may not yet work as expected and can break at any point. Releases happen often, so when you experience problems, make sure you are using the latest version (check with
npm outdated
in your project) before opening an issue.We are still in a phase where we can easily make bigger changes, so we ask you to please provide feedback on everything you notice - including, but not limited to
- developer experience (installation, typings, sourcemaps, framework integration, ...)
- hard to understand concepts and APIs
- wrong, missing, outdated or inaccurate documentation
- use-cases not covered by the API
- missing features
- and of course any bugs you encounter
Also, feel free to use GitHub discussions to ask questions or start a new discussion.
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 and Libraries.
This library is available on npm as @vis.gl/react-google-maps
.
npm install @vis.gl/react-google-maps
or
yarn add @vis.gl/react-google-maps
(PowerShell users: since @
has a special meaning in PowerShell, the
package name has to be quoted)
Import the APIProvider
and wrap it around all components that should have
access to the Google Maps 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
component inside the APIProvider
.
Within the Map
component, you can then add further components like
Marker
, AdvancedMarker
, or
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
.
import {APIProvider, Map, Marker} 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}>
<Marker position={position} />
</Map>
</APIProvider>
);
}
export default App;
Please see our documentation or examples for more in-depth information about this library.
Besides rendering maps, the Maps JavaScript API has a lot of additional 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()
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:
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={...}>
<MyComponent />
</APIProvider>
);
}
Explore our examples directory on GitHub or the examples on our website for full implementation examples.
0.10.0 (2024-05-03)
className
and style
props (92854c9)FAQs
React components and hooks for the Google Maps JavaScript API
The npm package @vis.gl/react-google-maps receives a total of 0 weekly downloads. As such, @vis.gl/react-google-maps popularity was classified as not popular.
We found that @vis.gl/react-google-maps demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.