Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.1.0 Not adding libraries (drawing/places etc) to maps api object #673

Closed
tim-soft opened this issue Nov 12, 2018 · 18 comments · Fixed by #921
Closed

v1.1.0 Not adding libraries (drawing/places etc) to maps api object #673

tim-soft opened this issue Nov 12, 2018 · 18 comments · Fixed by #921

Comments

@tim-soft
Copy link

Upgrading from v1.0.9 to v1.1.0, libraries are no longer added to the maps api object.

<GoogleMapReact
  bootstrapURLKeys={{
    key: 'xxxxxxxxxxxxxx',
    libraries: ['places', 'drawing'],
  }}
  yesIWantToUseGoogleMapApiInternals
  onGoogleApiLoaded={({ maps }) => {
    console.log(maps.places); // undefined
    console.log(maps.drawing); // undefined;
  }}
/>
@itsmichaeldiego
Copy link
Member

itsmichaeldiego commented Nov 13, 2018

@tim-soft Good catch!

This was introduced in #593

I think for the time being, instead of passing libraries as you were, you can do:

<GoogleMapReact
  bootstrapURLKeys={{
    key: 'xxxxxxxxxxxxxx',
    libraries: ["places", "drawing"],
  }}
  yesIWantToUseGoogleMapApiInternals
  onGoogleApiLoaded={({ maps }) => {
    console.log(maps.places);
    console.log(maps.drawing);
  }}
/>

@itsmichaeldiego
Copy link
Member

@tim-soft This was fixed and deployed in 1.1.1, please let me know!

@faeron
Copy link

faeron commented Nov 28, 2018

are both ways (as described in #681) broken now? For me using the "old" way doesn't work as long as heatmapLibrary={true} is used as described in the docs. It overrides set libraries here

The "new" way with using props for each library isn't working at all, as only the heatmapLayer prop seems to be usable, other libraries are not implemented yet I assume?

Is there any status on this and/or the PR?

@itsmichaeldiego
Copy link
Member

itsmichaeldiego commented Nov 28, 2018

@faeron I am sorry you're experiencing this, I reverted the change on 1.1.0 in 1.1.1, so it should work the same as 1.0.9, what is the problem you're experiencing?

@faeron
Copy link

faeron commented Nov 28, 2018

no worries :)
when using libraries in bootstrapURLKeys together with the propheatmapLibrary={true}it ignores all set libraries and only uses libraries=visualisation. This behavior seems to have the origin here
as it appends the libraries param again, which overrides the others (as it is set last). The other libraries are not loaded then.

I think it should not be a problem, when using it like in 1.0.9 only (without heatmap prop)

@itsmichaeldiego
Copy link
Member

@faeron I see the problem, we are working on a total fix with @DonovanDeSmedt

@itsmichaeldiego
Copy link
Member

@DonovanDeSmedt How are we looking on this man? Would love to see it happening

@DonovanDeSmedt
Copy link
Contributor

@itsmichaeldiego Lost it out of sight, I'll take a look at it the coming days

@barakplasma
Copy link
Contributor

barakplasma commented May 16, 2019

@DonovanDeSmedt would you like me to take over this issue for you? Specifically, to allow usage of bootstrapURLKeys.libraries prop array and the xyzLibrary={true} prop where we load all the libraries set to true from either source? We want to update the README.md to suggest one method or the other #686

@barakplasma
Copy link
Contributor

barakplasma commented May 16, 2019

As a recreation of the issue, see https://codesandbox.io/s/google-map-react-simple-map-yzeg2 which initializes a Google-Map-React map with the following props

<GoogleMapReact
          bootstrapURLKeys={{ key: "", libraries: ["places", "drawing"] }}
          defaultCenter={this.props.center}
          defaultZoom={this.props.zoom}
          heatmapLibrary={true}
>

and check the network requests. I see the following request
https://maps.googleapis.com/maps/api/js?callback=_$_google_map_initialize_$_&key=&libraries=places,drawing&libraries=visualization
from the package.json: "google-map-react": "1.1.4",

@pablolizardo
Copy link

Yes, in fact you have to disable the heatmapLibrary prop in order to get the libraries array working in the bootstrapURLKeys object.
image

@itsmichaeldiego
Copy link
Member

@ZAKdev Could you take a look at this?

@itsmichaeldiego
Copy link
Member

Merged and released in 2.1.0, let me know if everything works fine for you folks!

@itsmichaeldiego
Copy link
Member

Need to reopen this as I had to revert #921 which had a major bug.

Will wait for @aviyadeveloper to fix it properly without causing bugs!

@NgHLong
Copy link

NgHLong commented Sep 2, 2020

I got the problem with the "libraries" too, it's doubled the library, like when I import libraries = ["places"], it generates the url like this: &libraries=placesplaces

@itsmichaeldiego
Copy link
Member

@NgHLong That is true, we're working on it here #934, stay tuned

@NgHLong
Copy link

NgHLong commented Sep 3, 2020

Hey, just import the libraries and region ( libraries = ["places"], region: "VN"), and the URL will be fine.

@itsmichaeldiego
Copy link
Member

Merged in #946 and Released in version 2.1.4, let me know if you encounter any problems!

CC @NgHLong @pablolizardo @barakplasma @DonovanDeSmedt @faeron @tim-soft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants