2

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

1

1 Answer 1

2

Install the google maps api npm module and import it into your relevent files. https://www.npmjs.com/package/google-maps

Sign up to request clarification or add additional context in comments.

1 Comment

Yes ! That was unexpectedly easy ! Thank you !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.