17 lines
560 B
JavaScript
17 lines
560 B
JavaScript
/**
|
|
* @module searchInputHander
|
|
*/
|
|
|
|
/** Handles user pressing Enter key in search input field by sending current coordinates and contents of field to React Native for processing
|
|
* @param {Event} event - Keydown event in search input field
|
|
* @param {ol.Map} map - OpenLayers map
|
|
*/
|
|
const searchInputHander = (event, map) => {
|
|
if (event.key === "Enter") {
|
|
const coords = map.getView().getCenter();
|
|
const query = event.target.value;
|
|
window.ReactNativeWebView?.postMessage(`search@${coords}:${query}`);
|
|
}
|
|
};
|
|
|
|
export default searchInputHander;
|