Skip to content

Commit

Permalink
Fixed google maps loading multiple scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
aviklai committed Nov 9, 2020
1 parent cb5f6bf commit 6c333c7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
29 changes: 13 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-leaflet-google-layer",
"version": "2.0.0",
"version": "2.0.1",
"description": "React leaflet wrapper of leaflet.gridlayer.googlemutant",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ interface IProps extends L.gridLayer.GoogleMutantOptions {
apiKey?: string;
}

let googleMapsScriptLoaded = false;

const createLeafletElement = (props: IProps, context: LeafletContextInterface) => {
const { apiKey, useGoogMapsLoader = true, googleMapsLoaderConf = {}, googleMapsAddLayers, ...googleMutantProps } = props;
if (useGoogMapsLoader) {
if (useGoogMapsLoader && !googleMapsScriptLoaded) {
const loader = new Loader(apiKey, googleMapsLoaderConf);
loader.load();
googleMapsScriptLoaded = true;
}
const instance = L.gridLayer.googleMutant(googleMutantProps)
if (googleMapsAddLayers) {
Expand Down

0 comments on commit 6c333c7

Please sign in to comment.