Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

google map in 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;
Comment

react google map

npm install --save google-map-react
Comment

how to add google map in 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;
Comment

PREVIOUS NEXT
Code Example
Javascript :: queryselector j 
Javascript :: react native toggle button with text 
Javascript :: how to comment in javascript 
Javascript :: input variable in string javascript 
Javascript :: google places API details JS 
Javascript :: hide and show div using javascript with example 
Javascript :: how to add dropdown with filter in angular material 
Javascript :: mongoose remove 
Javascript :: constructer 
Javascript :: JavaScript HTML DOM Events 
Javascript :: adding int and string in react props 
Javascript :: javascript run function 
Javascript :: history of react js 
Javascript :: javascript.loop 
Javascript :: javascript set header text 
Javascript :: js code 
Javascript :: javascript css 
Javascript :: codewars js Shortest Word 
Javascript :: rest operator in javascript 
Javascript :: requestanimationframe in javascript 
Javascript :: javascript callbacks 
Javascript :: building an array of a numbers javascript 
Javascript :: add numbers from array nodejs 
Javascript :: how does an if statement work 
Javascript :: fastify testing 
Javascript :: javascript regex get domain from url 
Javascript :: set route on button in angular 
Javascript :: using settings_data.json shopify 
Javascript :: macam macam looping javascript 
Javascript :: vuejs cordoba pantalla en blanco 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =