reactjs - Getting GeoJson data from the map using React-Leaflet -


i'm trying retrieve geojson data of circle fixed radius on map. i'm not able understand how retrieve geojson data object map. according docs, using featuregroup should help, i'm failing understand how implement in react. in advance !

import react, {component} 'react';  import geosuggest 'react-geosuggest';  import { map, marker, popup, tilelayer, circle, featuregroup } 'react-leaflet';  import slider 'react-rangeslider';    class app extends react.component {      constructor(props) {      super(props);      this.state = {        lat: 18.572605,        lng: 73.878208,        zoom: 13,        value: 500      }      this.onsuggestselect = this.onsuggestselect.bind(this);    }      onsuggestselect(suggest) {      console.log(suggest)      this.setstate({        lat: suggest.location.lat,        lng: suggest.location.lng,      })    }      handlechangestart = () => {      console.log('change event started')    };      handlechange = value => {      this.setstate({        value: value      })    };      handlechangecomplete = () => {      console.log('change event completed')    };      render() {      const position = [this.state.lat, this.state.lng];      const { value } = this.state      return (        <div>            <h1>hello react :)</h1>            <geosuggest            onsuggestselect={this.onsuggestselect}            />            <div >              <map style={{height: '600px', width: '500px'}} center={position} zoom={this.state.zoom}>                <tilelayer                  attribution='&copy; <a href="http://osm.org/copyright">openstreetmap</a> contributors'                  url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'                />                <circle center={position} radius={value} color="#ff4e00" />                    <marker position={position}>                  <popup>                    <span>a pretty css3 popup. <br/> customizable.</span>                  </popup>                </marker>              </map>            </div>            <div classname='slider'>              <slider                min={0}                max={1000}                value={value}                onchangestart={this.handlechangestart}                onchange={this.handlechange}                onchangecomplete={this.handlechangecomplete}              />              <div classname='value'>{value}</div>            </div>        </div>        );    }  }  export default app;
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>  <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>

if you're trying create geojson circle, perhaps use library: https://www.npmjs.com/package/circle-to-polygon


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -