Gathering detailed insights and metrics for @beegru/react-location-picker
Gathering detailed insights and metrics for @beegru/react-location-picker
Gathering detailed insights and metrics for @beegru/react-location-picker
Gathering detailed insights and metrics for @beegru/react-location-picker
npm install @beegru/react-location-picker
Typescript
Module System
Node Version
NPM Version
55.6
Supply Chain
85.2
Quality
78.1
Maintenance
100
Vulnerability
97.3
License
Total Downloads
778
Last Day
1
Last Week
5
Last Month
22
Last Year
740
Minified
Minified + Gzipped
Latest Version
1.5.9
Package Id
@beegru/react-location-picker@1.5.9
Unpacked Size
15.50 kB
Size
5.27 kB
File Count
9
NPM Version
10.7.0
Node Version
20.13.1
Published on
May 14, 2024
Cumulative downloads
Total Downloads
2
4
A react component to pick a location using google maps.
1npm install react-location-picker --save
or
1yarn add react-location-picker --save
You need to include google map script in your page.
<script src="https://maps.googleapis.com/maps/api/js?key=<INSERT_API_KEY_HERE>&v=3.exp&libraries=geometry,drawing,places"></script>
1import React, { Component } from 'react'; 2import LocationPicker from 'react-location-picker'; 3 4/* Default position */ 5const defaultPosition = { 6 lat: 27.9878, 7 lng: 86.9250 8}; 9 10 11class LocationPickerExample extends Component { 12 constructor (props) { 13 super(props); 14 15 this.state = { 16 address: "Kala Pattar Ascent Trail, Khumjung 56000, Nepal", 17 position: { 18 lat: 0, 19 lng: 0 20 } 21 }; 22 23 // Bind 24 this.handleLocationChange = this.handleLocationChange.bind(this); 25 } 26 27 handleLocationChange ({ position, address, places }) { 28 29 // Set new location 30 this.setState({ position, address }); 31 } 32 33 render () { 34 return ( 35 <div> 36 <h1>{this.state.address}</h1> 37 <div> 38 <LocationPicker 39 containerElement={ <div style={ {height: '100%'} } /> } 40 mapElement={ <div style={ {height: '400px'} } /> } 41 defaultPosition={defaultPosition} 42 onChange={this.handleLocationChange} 43 /> 44 </div> 45 </div> 46 ) 47 } 48}
LocationPicker properties
Property | Type | Description |
---|---|---|
containerElement | node | required, A container element for map element |
mapElement | node | required, A map element |
onChange | function | required, A callback which gets called on every map marker position change, it is passed with one argument of type object which has location information. |
defaultPosition | object | required, A default position for map center. |
zoom | number | optional, Map zoom level |
radius | number | optional, Circle radius in meter. or Pass -1 to hide it. |
circleOptions | object | optional, https://developers.google.com/maps/documentation/javascript/3.exp/reference#CircleOptions |
For demo, clone this repo and run
Install all dependencies
yarn
Start
yarn start
Open http://localhost:8080
in your browser.
No vulnerabilities found.
No security vulnerabilities found.
Last Day
0%
1
Compared to previous day
Last Week
-44.4%
5
Compared to previous week
Last Month
-18.5%
22
Compared to previous month
Last Year
1,847.4%
740
Compared to previous year