“Отрешите карту Google” Ответ

Карта Google в React JS

import React, { Component } from 'react';
import GoogleMapReact from 'google-map-react';

const AnyReactComponent = ({ text }) => <div>{text}</div>;

class SimpleMap extends Component {
  static defaultProps = {
    center: {
      lat: 59.95,
      lng: 30.33
    },
    zoom: 11
  };

  render() {
    return (
      // Important! Always set the container height explicitly
      <div style={{ height: '100vh', width: '100%' }}>
        <GoogleMapReact
          bootstrapURLKeys={{ key: /* YOUR KEY HERE */ }}
          defaultCenter={this.props.center}
          defaultZoom={this.props.zoom}
        >
          <AnyReactComponent
            lat={59.955413}
            lng={30.337844}
            text="My Marker"
          />
        </GoogleMapReact>
      </div>
    );
  }
}

export default SimpleMap;
Scary Salmon

@React-Google-Maps/API NPM

npm i -S @react-google-maps/api
Evil Eagle

Отрешите карту Google

npm install --save google-map-react
Nutty Newt

Отрешите карты Google

npm i -S @react-google-maps/api
Open Owl

Как добавить карту Google в React JS

import React, { Component } from 'react';import GoogleMapReact from 'google-map-react'; const AnyReactComponent = ({ text }) => <div>{text}</div>; class SimpleMap extends Component {  static defaultProps = {    center: {      lat: 59.95,      lng: 30.33    },    zoom: 11  };   render() {    return (      // Important! Always set the container height explicitly      <div style={{ height: '100vh', width: '100%' }}>        <GoogleMapReact          bootstrapURLKeys={{ key: /* YOUR KEY HERE */ }}          defaultCenter={this.props.center}          defaultZoom={this.props.zoom}        >          <AnyReactComponent            lat={59.955413}            lng={30.337844}            text="My Marker"          />        </GoogleMapReact>      </div>    );  }} export default SimpleMap;
Uptight Unicorn

Ответы похожие на “Отрешите карту Google”

Вопросы похожие на “Отрешите карту Google”

Больше похожих ответов на “Отрешите карту Google” по JavaScript

Смотреть популярные ответы по языку

Смотреть другие языки программирования