mapbox / mapbox/mapbox-gl-geocoder
Adding an initial marker
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 388
- Forks
- 181
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to use with plugin as a widget to input geolocation of a venue. But I have two requirements:
- the marker should be draggable so users can make small changes to the pin position suggested by geocoder if they wish so
- if a venue is being edited and it already has a position, the map should reflect that by showing an initial marker, bound to the geolocation search
options.marker accepts a Boolean or an Object. I assumed the intent of the latter was precisely to pass an existing marker instance to use when searching. However, I've tried doing this and no initial marker is being shown on the map:
const map = new mapboxgl.Map({
container: map,
style: 'mapbox://styles/mapbox/streets-v11',
center: coords,
});
map.addControl(new MapboxGeocoder({
accessToken: mapboxgl.accessToken,
mapboxgl: mapboxgl,
coords: new mapboxgl.Marker({draggable: true}).setLngLat(coords)
}), 'top-left');
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with MapboxGeocoder's handling of the marker option and the mapboxgl.Marker setup shown in the issue. Reproduce the configuration with an existing draggable marker, then verify that the marker appears at the supplied coordinates and remains connected to the geocoder search behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100