Implementing google maps with react

前端 未结 4 408
陌清茗
陌清茗 2020-12-11 09:25

React newbie here, please bear with me : ) Hopefully this will be very simple to solve

For the moment, I am simply trying to get the map to appear on screen, but whe

4条回答
  •  囚心锁ツ
    2020-12-11 09:40

    This is an improved version of my previous answer

    I've just tested your code, which contains lots of errors, undefined and unused variables! Therefore, you can use the following code instead, which is quite simple (this will let you through the current problem and show the map!)

    First, install necessary libraries:

    npm install --save google-map-react
    npm install --save prop-types
    

    Then, you may copy the whole thing below:

    import React, { Component } from 'react';
    import GoogleMapReact from 'google-map-react';
    
    const AnyReactComponent = ({ text }) => 
    {text}
    ; class MyClass extends Component { constructor(props){ super(props); } render() { return ( ); } } MyClass.defaultProps = { center: {lat: 59.95, lng: 30.33}, zoom: 11 }; export default MyClass;

提交回复
热议问题