maptiler / maptiler-geocoding-control

The Javascript & TypeScript Map Control component for MapTiler Geocoding service! Easy to be integrated into any JavaScript mapping application.
https://maptiler.com/cloud/geocoding
BSD 3-Clause "New" or "Revised" License
31 stars 4 forks source link

[FEATURE] Allow control to be placed in an arbitrary position #60

Open jdudley1123 opened 2 days ago

jdudley1123 commented 2 days ago

I'm not sure whether this is something for Maptiler or for Leaflet, apologies if this is the wrong place.

Is your feature request related to a problem? Please describe. I'm adding the Maptiler Geocoding Control to a Leaflet map using the code:

L.control.maptilerGeocoding({ apiKey: "API_KEY" })
// from https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/leaflet/

The control is placed in the top right, and as far as I can tell there is no way to get it to be placed anywhere else. Adding position: 'topleft' (an option which is supported for most other controls) has no effect.

Describe the solution you'd like I'd like to be able to place the Geocoding Control like any other control.

Describe alternatives you've considered I tried overriding the position with CSS, but Leaflet puts controls in positional divs in such a way that this is not possible without moving all the controls in the top right.

zdila commented 2 days ago

Thanks for your report. As a workaround, you can use following code:

const geocodingControl = L.control
  .maptilerGeocoding({ apiKey })
  .setPosition("topleft")
  .addTo(map);