From 6eb8d29e90e824c85c4c2d5e50108a3ac146f45b Mon Sep 17 00:00:00 2001 From: Sam Samskies Date: Sat, 29 Aug 2020 16:07:31 -0700 Subject: [PATCH] Add marker prop --- README.md | 1 + package.json | 2 +- src/index.js | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f1726d7..c77003a 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/package.json b/package.json index 7ef46ab..cf3b459 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.js b/src/index.js index 4368632..e5f2ccc 100644 --- a/src/index.js +++ b/src/index.js @@ -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'] @@ -47,6 +48,7 @@ class Geocoder extends PureComponent { localGeocoder, reverseGeocode, enableEventLogging, + marker, render, getItemValue, onInit, @@ -73,7 +75,8 @@ class Geocoder extends PureComponent { localGeocoder, reverseGeocode, enableEventLogging, - marker: false + marker, + mapboxgl } if (render && typeof render === 'function') { @@ -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), @@ -279,6 +283,7 @@ class Geocoder extends PureComponent { limit: 5, reverseGeocode: false, enableEventLogging: true, + marker: true, position: 'top-right', onInit: () => {}, onClear: () => {},