1.0.3 • Published 3 years ago

@jswork/react-ant-geo-input v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-ant-geo-input

Geo input for react.

version license size download

installation

npm install -S @jswork/react-ant-geo-input

properties

NameTypeRequiredDefaultDescription
classNamestringfalse-The extended className for component.
appKeystringfalse'5Q5BZ-5EVWJ-SN5F3-K6QBZ-B3FAO-RVBWM'The map appKey from https://apis.map.qq.com/.
secretKeystringfalse'SWvT26ypwq5Nwb5RvS8cLi6NSoH8HlJX'SecretKey from https://lbs.qq.com/dev/console/application/mine.
valuestringfalse-The changed value.
lngnumberfalse-The longtitude of the address.
latnumberfalse-The latitude of the address.
onChangefuncfalsenoopThe change handler.
onErrorfuncfalsenoopThe handler when has error caught.
readOnlyboolfalsefalseIf lat/lng should be editalbe.

usage

  1. import css

    @import "~@jswork/react-ant-geo-input/dist/style.css";
    
    // or use sass
    @import "~@jswork/react-ant-geo-input/dist/style.scss";
    
    // customize your styles:
    $react-ant-geo-input-options: ()
  2. import js

    import ReactDemokit from '@jswork/react-demokit';
    import React from 'react';
    import ReactDOM from 'react-dom';
    import ReactAntGeoInput from '@jswork/react-ant-geo-input';
    import './assets/style.scss';
    
    class App extends React.Component {
      state = {
        value: '上海市浦东新区博云路2号浦软大厦5楼',
        lat: 31.202328,
        lng: 121.603882
      };
    
      render() {
        const { value, lat, lng } = this.state;
        return (
          <ReactDemokit
            className="p-3 app-container"
            url="https://github.com/afeiship/react-ant-geo-input">
            <ReactAntGeoInput
              value={value}
              lat={lat}
              lng={lng}
              onChange={(e) => {
                this.setState(e.target.value);
                console.log('e:', e.target.value);
              }}
            />
          </ReactDemokit>
        );
      }
    }
    
    ReactDOM.render(<App />, document.getElementById('app'));
  3. set proxy

     proxy: {
       '/ws/geocoder': 'https://apis.map.qq.com'
     }
  4. preview at: http://0.0.0.0:8080/

documentation

license

Code released under the MIT license.