You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
is there any way or interface to update the placeholder text to a different string than the one provided when initializing a MapboxGeocoder object, without creating a new instance?
When reassigning options.placeholder, the value changes, however it is not reflected in the state of the text input. Applying the same logic to the language attribute works though.
Consider this example:
constgeocoder=newMapboxGeocoder({
accessToken,language: 'en',placeholder: 'My placeholder when the app loads',
...
})// user performs an actiongeocoder.options.language='pt'// language is set to Portuguesegeocoder.options.placeholder='My placeholder when the user performed an action'// nothing happens
The standard way to do this would be using setters/getters for each of those options, so geocoder.setPlaceholder('your placeholder'), but those haven't been implemented, only get/setProximity have been implemented.
I can see how this would make it easier to change language without needing to remove, and re-add a new geocoder.
This was addressed in #226. That work introduced get and set functions for most options set-able in the constructor. It will be in the version4 release.
Activity
andrewharvey commentedon Jan 21, 2019
geocoder.options isn't exposed as part of the public API https://github.com/mapbox/mapbox-gl-geocoder/blob/master/API.md so there's no guarantees on what happens if you change it directly.
The standard way to do this would be using setters/getters for each of those options, so geocoder.setPlaceholder('your placeholder'), but those haven't been implemented, only get/setProximity have been implemented.
I can see how this would make it easier to change language without needing to remove, and re-add a new geocoder.
tristen commentedon Feb 28, 2019
Yeah hmm, perhaps something like a
geocoder.setOptions({})could work.[-]Custom placeholder text does not update[/-][+]Set different options after initialization[/+]scottsfarley93 commentedon Mar 22, 2019
This was addressed in #226. That work introduced get and set functions for most options set-able in the constructor. It will be in the version4 release.