Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-baidu-map

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-baidu-map

react component to work with baidu javascript API which enables you search, pinch and more

  • 1.3.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29
decreased by-58.57%
Maintainers
1
Weekly downloads
 
Created
Source

React Baidu Map

NPM version Build status Dependency Status Downloads

react component to work with baidu javascript API which enables you search, pinch and more

Installation

$ npm install --save react-baidu-map

Demo

demo

Usage

The following is an example to show how it works with a search input to get position of every marker from the map in real-time.

import { BaiduMap } from 'react-baidu-map';

class ExampleApp extends React.Component {
  render() {
    return (
      <div>
        <input onChange={this.onChange.bind(this)} />
        <BaiduMap id="location" ref="location" style={{height: 300}}
          onSelect={this.onSelect} />
      </div>
    );
  }
  onChange(event) {
    this.refs.location.search(event.target.value);
  }
  onSelect(point) {
    // point.lng
    // point.lat
  }
}

Before you start working on coding with Baidu API, you should add script to your main script:

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=your_key"></script>

API

Props

  • id {String} the id to create the map element in DOM tree, default value: "allmap".
  • style {Object} the style sheet to apply to the root element of this component.
  • onSelect {Function} this function will be fired when user click a marker and the info bubble is shown
    • point {Point} the position of being clicked to some maker
      • lng {String} the lng of the point.
      • lat {String} the lat of the point.

Methods

search(text: string): void

Search by keyword from the created map context.

License

MIT Licensed and WeFlex Copyright

Keywords

FAQs

Package last updated on 23 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc