Skip to content

Commit 6eb8d29

Browse files
committed
Add marker prop
1 parent de938e7 commit 6eb8d29

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Only `mapRef` and `mapboxApiAccessToken` are required.
6464
| 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.
6565
| reverseGeocode | Boolean | false | Enable reverse geocoding. Defaults to false. Expects coordinates to be lat, lon.
6666
| enableEventLogging | Boolean | true | Allow Mapbox to collect anonymous usage statistics from the plugin.
67+
| 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.
6768
| 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.
6869
| 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"`.
6970
| onInit | Function | () => {} | Is passed Mapbox geocoder instance as param and is executed after Mapbox geocoder is initialized.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-map-gl-geocoder",
3-
"version": "2.0.16",
3+
"version": "2.1.0",
44
"description": "React wrapper for mapbox-gl-geocoder for use with react-map-gl",
55
"source": "src/index.js",
66
"main": "dist/index.js",

src/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types'
33
import MapboxGeocoder from '@mapbox/mapbox-gl-geocoder'
44
import { FlyToInterpolator } from 'react-map-gl'
55
import WebMercatorViewport from 'viewport-mercator-project'
6+
import mapboxgl from 'mapbox-gl'
67

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

@@ -47,6 +48,7 @@ class Geocoder extends PureComponent {
4748
localGeocoder,
4849
reverseGeocode,
4950
enableEventLogging,
51+
marker,
5052
render,
5153
getItemValue,
5254
onInit,
@@ -73,7 +75,8 @@ class Geocoder extends PureComponent {
7375
localGeocoder,
7476
reverseGeocode,
7577
enableEventLogging,
76-
marker: false
78+
marker,
79+
mapboxgl
7780
}
7881

7982
if (render && typeof render === 'function') {
@@ -255,6 +258,7 @@ class Geocoder extends PureComponent {
255258
localGeocoder: PropTypes.func,
256259
reverseGeocode: PropTypes.bool,
257260
enableEventLogging: PropTypes.bool,
261+
marker: PropTypes.bool,
258262
render: PropTypes.func,
259263
getItemValue: PropTypes.func,
260264
position: PropTypes.oneOf(VALID_POSITIONS),
@@ -279,6 +283,7 @@ class Geocoder extends PureComponent {
279283
limit: 5,
280284
reverseGeocode: false,
281285
enableEventLogging: true,
286+
marker: true,
282287
position: 'top-right',
283288
onInit: () => {},
284289
onClear: () => {},

0 commit comments

Comments
 (0)