Search code examples
javascriptjquerygoogle-mapsgoogle-maps-api-3

Load additional Google Maps libraries dynamically


I've got a page where the Google Maps is being loaded with the Geometry library:

<script src="//maps.googleapis.com/maps/api/js?v=3.exp&key=xxx&language=en&libraries=geometry"></script>

Is there a way, if I only have access to update the javascript on this page, to also load in the Places library? i.e. I can't update or remove the HTML for the above script tag.

I know there's already a feature request to get this added to the API:

And this question has already been asked, without answer, 3 years ago:

I'm hoping someone might have come up with a way to do this since then.


Solution

  • This feature is now available in the v=beta channel of the Google Maps JavaScript API: https://developers.google.com/maps/documentation/javascript/dynamic-loading

    If you have any issues using this API, please report them at https://developers.google.com/maps/documentation/javascript/support#issue-tracker