@vis.gl/react-google-maps
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -722,5 +722,5 @@ (function (global, factory) { | ||
if (!map || !markersLibraryReady) return; | ||
var marker = new google.maps.marker.AdvancedMarkerElement(); | ||
marker.map = map; | ||
setMarker(marker); | ||
var newMarker = new google.maps.marker.AdvancedMarkerElement(); | ||
newMarker.map = map; | ||
setMarker(newMarker); | ||
// create container for marker content if there are children | ||
@@ -730,7 +730,7 @@ if (numChilds > 0) { | ||
if (className) el.classList.add(className); | ||
marker.content = el; | ||
newMarker.content = el; | ||
setContentContainer(el); | ||
} | ||
return function () { | ||
if (marker) marker.map = null; | ||
newMarker.map = null; | ||
setMarker(null); | ||
@@ -854,15 +854,10 @@ setContentContainer(null); | ||
if (!map) { | ||
if (map === undefined) { | ||
console.error('<Marker> has to be inside a Map component.'); | ||
} | ||
if (map === undefined) console.error('<Marker> has to be inside a Map component.'); | ||
return; | ||
} | ||
var m = new google.maps.Marker(markerOptions); | ||
m.setMap(map); | ||
setMarker(m); | ||
// remove from map on unmount | ||
var newMarker = new google.maps.Marker(markerOptions); | ||
newMarker.setMap(map); | ||
setMarker(newMarker); | ||
return function () { | ||
if (marker) { | ||
marker.setMap(null); | ||
} | ||
newMarker.setMap(null); | ||
setMarker(null); | ||
@@ -869,0 +864,0 @@ }; |
{ | ||
"name": "@vis.gl/react-google-maps", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "React components and hooks for Google Maps.", | ||
@@ -5,0 +5,0 @@ "source": "src/index.ts", |
@@ -1,2 +0,2 @@ | ||
# React Components for the Google Maps API | ||
# React Components for the Google Maps JavaScript API | ||
@@ -8,3 +8,3 @@ [![MIT License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/visgl/react-google-maps/tree/main/LICENSE) | ||
The hooks provide the possibility to access different Google Maps services and libraries, as well as the map instance | ||
The hooks provide the possibility to access different Google Maps Platform services and libraries, as well as the map instance | ||
itself inside all components that are wrapped inside the `APIProvider`. | ||
@@ -15,10 +15,12 @@ The map instance can only be accessed, if a `Map` component is used inside the `APIProvider`. | ||
This is a Typescript / JavaScript library to integrate the Google Maps JavaScript API into your React application. | ||
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 Google Maps | ||
hooks to use some of the Maps JavaScript | ||
API [Services](https://developers.google.com/maps/documentation/javascript#services) | ||
and [Libraries](https://developers.google.com/maps/documentation/javascript#libraries). | ||
and [Libraries](https://developers.google.com/maps/documentation/javascript/libraries). | ||
## Installation | ||
This library is available via npm as the package [@vis.gl/react-google-maps](https://www.npmjs.com/package/@vis.gl/react-google-maps). | ||
```sh | ||
@@ -58,3 +60,3 @@ npm install --save @vis.gl/react-google-maps -D | ||
The `APIProvider` is used to load the Google Maps JavaScript API at the top level of the app component and provides a | ||
The `APIProvider` is used to load the Maps JavaScript API at the top level of the app component and provides a | ||
context that holds all map instances that can be accessed via the `useMap` hook. | ||
@@ -140,8 +142,8 @@ | ||
## Using other libraries of the Google Maps API | ||
## Using other libraries of the Google Maps JavaScript API | ||
Besides rendering maps, the Google Maps API has a lot of additional libraries | ||
for things like geocoding, routing, the places API and a lot more. These libraries | ||
Besides rendering maps, 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 loading of those libraries. | ||
`useMapsLibrary()` to handle dynamic loading of those libraries. | ||
@@ -148,0 +150,0 @@ For example, if you want to write a component that needs to use the |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
209
351499
4844