gpt4 book ai didi

javascript - dburles meteor Google map API 错误 : MissingKeyMapError

转载 作者:行者123 更新时间:2023-11-28 05:12:18 27 4
gpt4 key购买 nike

我正在使用这个 Meteor 包,https://github.com/dburles/meteor-google-maps-react-example/blob/master/imports/lib/GoogleMap.js

解决了我加载 GoogleMaps 的问题后, Google map for meteor

我遇到了一个新错误,Google map API 错误:MissingKeyMapError

如何解决这个问题?我什么时候可以放置我的 API 凭据?

最佳答案

我正在使用fullstackreact/google-maps-react

npm install --save google-maps-react

然后创建一个谷歌地图组件。

import React, {PropTypes} from 'react';
import Map, {GoogleApiWrapper, Marker} from 'google-maps-react';

export class Container extends React.Component {
render() {
if (!this.props.loaded) {
return <div>Loading...</div>
}

return (
<Map google={this.props.google}
zoom={12}
initialCenter={{lat: this.props.lat, lng: this.props.lng}}
style={{width: '100%', height: '100%', position: 'relative'}}>
</Map>
)
}
}
export default GoogleApiWrapper({
apiKey: <YOUR_KEY_HERE>
})(Container)

创建上述 Container.jsx 文件后,将其作为组件导入,然后将其用作:

 import Container from './Container.jsx';
...
<Container lat={YOUR_LAT} lng={YOUR_LNG} />

这是使用库的基本方法,您可以添加标记、标签等。详情请访问How to Write a Google Maps React Component

关于javascript - dburles meteor Google map API 错误 : MissingKeyMapError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41261334/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com