2 回答

TA貢獻(xiàn)1846條經(jīng)驗(yàn) 獲得超7個贊
2天前有同樣的問題。該庫已過時,不再維護(hù)。我建議你google-map-react
改用。我發(fā)現(xiàn)那個庫更可靠。
Github:https : //github.com/google-map-react/google-map-react
NPM:https : //www.npmjs.com/package/google-map-react

TA貢獻(xiàn)1963條經(jīng)驗(yàn) 獲得超6個贊
根據(jù)文檔,google必須從裝飾的組件道具中獲取實(shí)例。
import { Map, GoogleApiWrapper } from 'google-maps-react';
import React from 'react';
import '../css/MapContainer.css';
const MapContainer = ({ t, google }) => (
<Map class="location_map"
google={google}
zoom={8}
initialCenter={{ lat: 47.444, lng: -122.176}}/>
)
export default GoogleApiWrapper({
apiKey: '...'
})(MapContainer);
添加回答
舉報(bào)