React-google-maps: how to correctly load the google maps API using only the script tag instead of using withProps()/props

Created on 18 Jan 2018  路  1Comment  路  Source: tomchentw/react-google-maps

How do i correctly load the google maps lib in react-google-maps using

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC4R6AN7SmujjPUIGKdyao2Kqitzr1kiRg&v=3.exp&libraries=geometry,drawing,places"></script>

Instead of withProps({googleMapURL: "google maps library"}) or passing googleMapURL: "google maps library" as props to the component.

I need this because using withProps({googleMapURL: "google maps library"}) or passing it as props,causes the Google Maps API to be included multiple times whenever a component using the map and another component using the search box renders on the same page.

I have tried including the Script above in my index.html file but it didn't work. Please,what am i doing wrong?

Most helpful comment

Removing withScriptjs and adding the script like so
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC4R6AN7SmujjPUIGKdyao2Kqitzr1kiRg&v=3.exp&libraries=geometry,drawing,places"></script>
solved the problem for me

>All comments

Removing withScriptjs and adding the script like so
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC4R6AN7SmujjPUIGKdyao2Kqitzr1kiRg&v=3.exp&libraries=geometry,drawing,places"></script>
solved the problem for me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bansalvks picture bansalvks  路  3Comments

Mahmood004 picture Mahmood004  路  3Comments

LukasZvikas picture LukasZvikas  路  3Comments

johnantoni picture johnantoni  路  3Comments

tahir-masood1 picture tahir-masood1  路  4Comments