Reputation: 3805
I currently try to use google map API with react js and babel. I don't want to use the existing react components (that are uncomplete).
The problem I encounter is that I can't load the google map object. Babel always show me a compilation error like this one :
error 'google' is not defined
Event if I load the google map script in my index :
<script src="https://maps.googleapis.com/maps/api/js?key=MY_KEY&libraries=places&callback=initAutocomplete" ></script>
I understand that babel doesn't load the google map library at compile time, but try to compile some code lines like this :
var map = new google.maps.Map(document.getElementById('map')...
Is there someone who know how to handle this case ?
Thank you
Upvotes: 2
Views: 1199
Reputation: 3072
Install the google maps api npm module and import it into your relevent files. https://www.npmjs.com/package/google-maps
Upvotes: 2