I am developing an application on meteor.js and I need to connect a script with Google maps for only one page with maps. I connect it to the class constructor.
class Map extends React.Component { constructor() { super(); const script = document.createElement("script"); script.src = "https://maps.googleapis.com/maps/api/js?key=API-KEY&callback=initMap"; script.async = true; script.defer = true; document.head.appendChild(script); this.panToArcDeTriomphe = this.panToArcDeTriomphe.bind(this); } componentDidMount() { this.map = new google.maps.Map(this.refs.map, { center: {lat:48.858608, lng:2.294471}, zoom:16 } ); } panToArcDeTriomphe() { console.log(this) this.map.panTo({ lat:48.873947, lng:2.295038}); } render() { const mapStyle = {width:500, height:300, border:'1px solid black' }; return ( <div> <button onClick={this.panToArcDeTriomphe}>Go to</button> <div ref="map" style={mapStyle}>I should be a map</div> </div> ); } } ReactDOM.render(<Map />, document.getElementById('root')); But I get this error:
Uncaught ReferenceError: google is not defined
The code for this example is in codepen: http://codepen.io/alex183/pen/XpJJPz?editors=0011
I can not understand what the problem is, the script is visible on the page, but the maps do not work. 
https://maps.googleapis.com/maps/api/jsBEFORE or AFTER you have hooked up? Is the script using it higher or lower in the DOM tree? - VenZell