googlemaps / js-samples

Samples for the Google Maps JavaScript v3 API
https://developers.google.com/maps/documentation/javascript/
Other
730 stars 817 forks source link

Autocomplete Widget example wrongly loads the Map class from the "places" library #1766

Open andreimirt opened 1 week ago

andreimirt commented 1 week ago

Operating system

Windows 11

Browser Version

Firefox 127

How severe is the bug?

low

Bug description

This example that loads an Autocomplete Widget tries to load the Map class from the "places" library. The example still works as intended because the Map class isn't required anywhere, so the"places" library is loaded anyway and then the PlaceAutocompleteElement class is referenced using the full namespace. The guide is made to be easy enough for non-js gurus. Probably js-gurus don't even bother with the guides and read just the reference, but it took me a full day to understand what #L11 actually does, because I started with the assumption that the official documentation is always correct. Now I know better. :smi https://github.com/googlemaps/js-samples/blob/ce94ea122e565fad7fd2152c950eea8e4f4747eb/dist/samples/place-autocomplete-element/docs/index.js#L7-L47

Steps to reproduce

Just run the JSFiddle example, to which I added a console.log('Map: ',Map) after the attempt to load the Map class from the "places" library is made.

Console log output

"Map: ", undefined