这个错误通常是因为在使用react-google-maps组件时忘记传递所需的props。确保在使用
示例代码如下:
import React from ‘react’;
import { GoogleMap, withScriptjs, withGoogleMap } from ‘react-google-maps’;
function Map() {
return (
);
}
const MyMapComponent = withScriptjs(withGoogleMap(Map));
function App() {
return (
}
googleMapURL={`https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,drawing,places&key=YOUR_API_KEY`}
containerElement={}
mapElement={}
/>
);
}
export default App;
注意,在实际使用中,请替换“YOUR_API_KEY”为你自己的Google Maps API密钥。