dburles meteor Ошибка API Карт Google: MissingKeyMapError

Я использую этот пакет Meteor, https://github.com/dburles/meteor-google-maps-react-example/blob/master/imports/lib/GoogleMap.js

После решения моей проблемы в Загрузка GoogleMaps, карта Google для метеора

Я обнаружил новую ошибку: ошибка API Карт Google: MissingKeyMapError

Как я могу решить эту проблему? Когда я могу поставить свои учетные данные API?

1 ответ

Я использую https://github.com/fullstackreact/google-maps-react

npm install --save google-maps-react

Затем создайте компонент карты Google.

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} />

Это основной способ использования библиотеки, вы можете добавлять маркеры, метки и другие. Для получения подробной информации, пожалуйста, посетите Как написать компонент Google Maps React

Другие вопросы по тегам