mapbox-gl-geocoder icon indicating copy to clipboard operation
mapbox-gl-geocoder copied to clipboard

forcing suggestions using geocoder to display above search bar

Open EuropeanWaterProject opened this issue 6 years ago • 4 comments

Hello,

I am using the geocoder in the bottom right postion. Suggestions are displaying below the search bar outside of the visual area when I access my page from a phone. How can I force using css the search suggestions to show above the search bar.

Thanks,

Stuart

EuropeanWaterProject avatar Nov 17 '19 11:11 EuropeanWaterProject

Would likewise appreciate some insight on how to set the results to display above the map.

songololo avatar Nov 26 '19 10:11 songololo

For now the only option seems to be overriding the CSS.

.suggestions {
  top: auto !important;
  bottom: 100% !important;
}

It seems that these CSS adjustments are applied automatically when adding the geocoder to a map if using the lower-left or lower-right locations... but isn't applied when adding to a div (since no context on location is available).

Would be nice to have an option available (in the options object) to force an upwards display.

songololo avatar Nov 26 '19 11:11 songololo

This worked for me :

in CSS

.geocoder { position: absolute; z-index: 20; right: 10%; top: 14%; text-decoration: none; list-style-type: none; }

In body script ... var geocoder = new MapboxGeocoder({

accessToken: mapboxgl.accessToken, mapboxgl: mapboxgl });

document.getElementById('geocoder').appendChild(geocoder.onAdd(map));

EuropeanWaterProject avatar Nov 26 '19 12:11 EuropeanWaterProject

I'd be happy to help review a PR which fixes this.

andrewharvey avatar Dec 14 '19 04:12 andrewharvey