jw-google-map

0.1.1 • Public • Published

jw-google-map

A react component for google map.

NPM version build status node version npm download

Demo

Install

NPM

Static Methods

Method Parameters Description
setAPIKey api: string. set the API key for google map and reload the Map API script.

Methods

Method Parameters Description
getMapCenter retrieve the lat and long of the center of the map view.
setMarker position: object consist of
{ lat: number, lng: number }.
set a marker on a given position of map.

Props

Prop Description
center(optional) the initial center of the map. Default: { lat: 0, lng: 0 }
zoom(optional) the initial zoom of the map. Default: 0

Usage

import React, { Component } from "react";
import ReactDOM from "react-dom";
import Map, { setAPIKey } from "jw-google-map";
 
import "./style.css";
 
class Demo extends Component {
  conponentDidMount() {
    setAPIKey(`<API KEY HERE>`);
 
    const { map } = this;
 
    const position = map.getMapCenter();
 
    map.setMarker(position);
  }
 
  render() {
    return <Map ref={m => (this.map = m)} />;
  }
}
 
ReactDOM.render(<Demo />, document.getElementById("root"));

Readme

Keywords

Package Sidebar

Install

npm i jw-google-map

Weekly Downloads

3

Version

0.1.1

License

MIT

Unpacked Size

515 kB

Total Files

21

Last publish

Collaborators

  • johnwong