Update geocoder to 1.6.0 (#920)

This is to update geocoder to latest version which now have types and is
fully modernized.
This commit is contained in:
Harel M
2024-08-21 08:56:59 +03:00
committed by GitHub
parent 6a0d2e8ee5
commit 8184ac8393
3 changed files with 12 additions and 12 deletions

13
package-lock.json generated
View File

@@ -10,7 +10,7 @@
"license": "MIT",
"dependencies": {
"@mapbox/mapbox-gl-rtl-text": "^0.2.3",
"@maplibre/maplibre-gl-geocoder": "^1.5.0",
"@maplibre/maplibre-gl-geocoder": "^1.6.0",
"@maplibre/maplibre-gl-inspect": "^1.6.3",
"@maplibre/maplibre-gl-style-spec": "^20.1.1",
"@mdi/js": "^7.4.47",
@@ -1626,20 +1626,21 @@
}
},
"node_modules/@maplibre/maplibre-gl-geocoder": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-geocoder/-/maplibre-gl-geocoder-1.5.0.tgz",
"integrity": "sha512-PsAbV7WFIOu5QYZne95FiXoV7AV1/6ULMjQxgInhZ5DdB0hDLjciQPegnyDgkzI8JfeqoUMZVS/MglZnSZYhyQ==",
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-geocoder/-/maplibre-gl-geocoder-1.6.0.tgz",
"integrity": "sha512-SU4cv1P+8ALZlGYLPNvlENadH4zzn8Lw5ajmhbmJgWdC/NzxGFS+u4TITSL8tjzhMFU4jepo42HvNmGtDJjFuQ==",
"dependencies": {
"events": "^3.3.0",
"lodash.debounce": "^4.0.6",
"subtag": "^0.5.0",
"suggestions-list": "^0.0.2",
"xtend": "^4.0.1"
},
"engines": {
"node": ">=6"
"node": ">=18"
},
"peerDependencies": {
"maplibre-gl": ">=1.14.0"
"maplibre-gl": ">=4.0.0"
}
},
"node_modules/@maplibre/maplibre-gl-inspect": {

View File

@@ -23,7 +23,7 @@
"homepage": "https://github.com/maplibre/maputnik#readme",
"dependencies": {
"@mapbox/mapbox-gl-rtl-text": "^0.2.3",
"@maplibre/maplibre-gl-geocoder": "^1.5.0",
"@maplibre/maplibre-gl-geocoder": "^1.6.0",
"@maplibre/maplibre-gl-inspect": "^1.6.3",
"@maplibre/maplibre-gl-style-spec": "^20.1.1",
"@mdi/js": "^7.4.47",

View File

@@ -11,8 +11,7 @@ import { HighlightedLayer, colorHighlightedLayer } from '../libs/highlight'
import 'maplibre-gl/dist/maplibre-gl.css'
import '../maplibregl.css'
import '../libs/maplibre-rtl'
//@ts-ignore
import MaplibreGeocoder from '@maplibre/maplibre-gl-geocoder';
import MaplibreGeocoder, { MaplibreGeocoderApi, MaplibreGeocoderApiConfig } from '@maplibre/maplibre-gl-geocoder';
import '@maplibre/maplibre-gl-geocoder/dist/maplibre-gl-geocoder.css';
import { withTranslation, WithTranslation } from 'react-i18next'
@@ -222,7 +221,7 @@ class MapMaplibreGlInternal extends React.Component<MapMaplibreGlInternalProps,
initGeocoder(map: Map) {
const geocoderConfig = {
forwardGeocode: async (config:{query: string, limit: number, language: string[]}) => {
forwardGeocode: async (config: MaplibreGeocoderApiConfig) => {
const features = [];
try {
const request = `https://nominatim.openstreetmap.org/search?q=${config.query}&format=geojson&polygon_geojson=1&addressdetails=1`;
@@ -255,8 +254,8 @@ class MapMaplibreGlInternal extends React.Component<MapMaplibreGlInternalProps,
return {
features
};
}
};
},
} as unknown as MaplibreGeocoderApi;
const geocoder = new MaplibreGeocoder(geocoderConfig, {
placeholder: this.props.t("Search"),
maplibregl: MapLibreGl,