Mapbox Geocoder 与屏幕键盘集成
Mapbox Geocoder integration with on-screen keyboard
我试用了这个 mapbox 地理编码示例:
https://docs.mapbox.com/mapbox-gl-js/example/mapbox-gl-geocoder/
在我的申请中。
现在,我正在尝试做同样的事情,但不是使用物理键盘,而是尝试使用屏幕键盘,例如:
https://virtual-keyboard.js.org/
但目前,来自虚拟键盘的输入未触发 mapbox 地理编码器。我怎样才能link这两个组件?
如 keyevent
函数 here in the mapbox/mapbox-gl-geocoder
source code, the geocoder responds to keydown
events 的实现所示,当按下某个键时会触发。
您链接的虚拟键盘的文档包含 onKeyPress
method to which you can pass a callback function to be executed when a key is pressed on the virtual keyboard. You can implement a function to simulate a keydown
event (as described in this Stack Overflow post) equivalent to the last character from getInput
。这应该具有触发地理编码器的效果,就像按下实际键一样。
我试用了这个 mapbox 地理编码示例: https://docs.mapbox.com/mapbox-gl-js/example/mapbox-gl-geocoder/ 在我的申请中。
现在,我正在尝试做同样的事情,但不是使用物理键盘,而是尝试使用屏幕键盘,例如: https://virtual-keyboard.js.org/
但目前,来自虚拟键盘的输入未触发 mapbox 地理编码器。我怎样才能link这两个组件?
如 keyevent
函数 here in the mapbox/mapbox-gl-geocoder
source code, the geocoder responds to keydown
events 的实现所示,当按下某个键时会触发。
您链接的虚拟键盘的文档包含 onKeyPress
method to which you can pass a callback function to be executed when a key is pressed on the virtual keyboard. You can implement a function to simulate a keydown
event (as described in this Stack Overflow post) equivalent to the last character from getInput
。这应该具有触发地理编码器的效果,就像按下实际键一样。