Skip to content

Commit

Permalink
Add marker prop
Browse files Browse the repository at this point in the history
  • Loading branch information
SamSamskies committed Aug 29, 2020
1 parent de938e7 commit 6eb8d29
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Only `mapRef` and `mapboxApiAccessToken` are required.
| localGeocoder | Function | | A function accepting the query string which performs local geocoding to supplement results from the Mapbox Geocoding API. Expected to return an Array of GeoJSON Features in the [Carmen GeoJSON](https://github.com/mapbox/carmen/blob/master/carmen-geojson.md) format.
| reverseGeocode | Boolean | false | Enable reverse geocoding. Defaults to false. Expects coordinates to be lat, lon.
| enableEventLogging | Boolean | true | Allow Mapbox to collect anonymous usage statistics from the plugin.
| marker | Boolean or Object | true | If true, a Marker will be added to the map at the location of the user-selected result using a default set of Marker options. If the value is an object, the marker will be constructed using these options. If false, no marker will be added to the map.
| render | Function | | A function that specifies how the results should be rendered in the dropdown menu. Accepts a single Carmen GeoJSON object as input and return a string. Any html in the returned string will be rendered. Uses mapbox-gl-geocoder's default rendering if no function provided.
| position | String | "top-right" | Position on the map to which the geocoder control will be added. Valid values are `"top-left"`, `"top-right"`, `"bottom-left"`, and `"bottom-right"`.
| onInit | Function | () => {} | Is passed Mapbox geocoder instance as param and is executed after Mapbox geocoder is initialized.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-map-gl-geocoder",
"version": "2.0.16",
"version": "2.1.0",
"description": "React wrapper for mapbox-gl-geocoder for use with react-map-gl",
"source": "src/index.js",
"main": "dist/index.js",
Expand Down
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'
import MapboxGeocoder from '@mapbox/mapbox-gl-geocoder'
import { FlyToInterpolator } from 'react-map-gl'
import WebMercatorViewport from 'viewport-mercator-project'
import mapboxgl from 'mapbox-gl'

const VALID_POSITIONS = ['top-left', 'top-right', 'bottom-left', 'bottom-right']

Expand Down Expand Up @@ -47,6 +48,7 @@ class Geocoder extends PureComponent {
localGeocoder,
reverseGeocode,
enableEventLogging,
marker,
render,
getItemValue,
onInit,
Expand All @@ -73,7 +75,8 @@ class Geocoder extends PureComponent {
localGeocoder,
reverseGeocode,
enableEventLogging,
marker: false
marker,
mapboxgl
}

if (render && typeof render === 'function') {
Expand Down Expand Up @@ -255,6 +258,7 @@ class Geocoder extends PureComponent {
localGeocoder: PropTypes.func,
reverseGeocode: PropTypes.bool,
enableEventLogging: PropTypes.bool,
marker: PropTypes.bool,
render: PropTypes.func,
getItemValue: PropTypes.func,
position: PropTypes.oneOf(VALID_POSITIONS),
Expand All @@ -279,6 +283,7 @@ class Geocoder extends PureComponent {
limit: 5,
reverseGeocode: false,
enableEventLogging: true,
marker: true,
position: 'top-right',
onInit: () => {},
onClear: () => {},
Expand Down

0 comments on commit 6eb8d29

Please sign in to comment.