3
3
/// <reference types="mapbox-gl" />
4
4
/// <reference types="maplibre-gl" />
5
5
6
+ import L = require( 'leaflet' ) ;
7
+
6
8
declare class AbstractPlaces {
7
9
constructor ( options : JawgPlaces . JawgPlacesOptions ) ;
8
10
/**
@@ -151,7 +153,7 @@ declare namespace JawgPlaces {
151
153
accessToken ?: string ;
152
154
/**
153
155
* The `<input>` to transform into a geocoding search bar.
154
- * This can be either a id (e.g `#my-input`), class selector (e.g `.my-input`) or the { @link HTMLElement} .
156
+ * This can be either a id (e.g `#my-input`), class selector (e.g `.my-input`) or the [ HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) .
155
157
* With some frameworks/UI libs such as React, you can't use the ref here.
156
158
*/
157
159
input ?: string | HTMLElement ;
@@ -321,14 +323,20 @@ declare namespace JawgPlaces {
321
323
* Options for {@link JawgPlaces.MapLibre} and {@link JawgPlaces.Mapbox}
322
324
*/
323
325
interface JawgPlacesMaplibreOptions extends JawgPlacesOptions {
326
+ /**
327
+ * The custom `<div>` that will contain the input and geocoding results when Places JS is used as MapLibre Control.
328
+ * By default this is generated by Jawg Places JS.
329
+ * With some frameworks/UI libs such as React, you can't use the ref here.
330
+ */
331
+ container ?: string | HTMLElement ;
324
332
/**
325
333
* Placeholder text to add when the input in generated by the library.
326
334
*/
327
335
placeholder ?: string ;
328
336
/**
329
337
* Class to add to the input when it's generated by the library.
330
338
*/
331
- inputClasses ?: string ;
339
+ inputClasses ?: string | string [ ] ;
332
340
/**
333
341
* Option to show administrative area when available.
334
342
*/
@@ -341,20 +349,30 @@ declare namespace JawgPlaces {
341
349
* Option to configure transition on result selection.
342
350
*/
343
351
transition ?: MapGLTransitionOptions ;
352
+ /**
353
+ * Set a custom message when no results are found. This can be disabled.
354
+ */
355
+ noResultsMessage ?: string | false ;
344
356
}
345
357
346
358
/**
347
359
* Options for {@link JawgPlaces.Leaflet}
348
360
*/
349
361
interface JawgPlacesLeafletOptions extends JawgPlacesOptions {
362
+ /**
363
+ * The custom `<div>` that will contain the input and geocoding results when Places JS is used as Leaflet Control.
364
+ * By default this is generated by Jawg Places JS.
365
+ * With some frameworks/UI libs such as React, you can't use the ref here.
366
+ */
367
+ container ?: string | HTMLElement ;
350
368
/**
351
369
* Placeholder text to add when the input in generated by the library.
352
370
*/
353
371
placeholder ?: string ;
354
372
/**
355
373
* Class to add to the input when it's generated by the library.
356
374
*/
357
- inputClasses ?: string ;
375
+ inputClasses ?: string | string [ ] ;
358
376
/**
359
377
* Option to show administrative area when available.
360
378
*/
@@ -367,14 +385,18 @@ declare namespace JawgPlaces {
367
385
* Option to configure transition on result selection.
368
386
*/
369
387
transition ?: LeafletTransitionOptions ;
388
+ /**
389
+ * Set a custom message when no results are found. This can be disabled.
390
+ */
391
+ noResultsMessage ?: string | false ;
370
392
/**
371
393
* Position of the input on the map.
372
394
*/
373
395
position ?: 'topleft' | 'topright' | 'bottomleft' | 'bottomright' ;
374
396
/**
375
397
* The Leaflet instance for marker creation
376
398
*/
377
- L : any ;
399
+ L : typeof L ;
378
400
}
379
401
380
402
/**
@@ -388,18 +410,20 @@ declare namespace JawgPlaces {
388
410
* This class will help you to add or use search bar for geocoding with a MapLibre GL JS map.
389
411
*/
390
412
class MapLibre extends AbstractPlaces {
391
- constructor ( options : JawgPlacesMaplibreOptions ) ;
413
+ constructor ( options ? : JawgPlacesMaplibreOptions ) ;
392
414
/**
393
- * This is the function used by MapLibre and Mapbox when you add a { @link mapboxgl.Control} .
415
+ * This is the function used by MapLibre and Mapbox when you add a [maplibre.IControl](https://maplibre.org/maplibre-gl-js-docs/api/markers/#icontrol) or [ mapboxgl.IControl](https://docs.mapbox.com/mapbox-gl-js/api/markers/#icontrol) .
394
416
* Adds the control to the given map.
395
- * @param map from MapLibre or Mapbox
417
+ * @param map from [MapLibre](https://maplibre.org/maplibre-gl-js-docs/api/map/) or [Mapbox](https://docs.mapbox.com/mapbox-gl-js/api/map/)
418
+ * @returns the generated control container
396
419
*/
397
- onAdd ( map : mapboxgl . Map ) : HTMLElement ;
420
+ onAdd ( map : maplibregl . Map | mapboxgl . Map ) : HTMLElement ;
398
421
/**
399
- * When Jawg Places is not used as a control within your map, you will need to call this function.
400
- * @param map from MapLibre or Mapbox
422
+ * When Jawg Places **is not used** as a control within your map, you will need to call this function.
423
+ * @param map from [MapLibre](https://maplibre.org/maplibre-gl-js-docs/api/map/) or [Mapbox](https://docs.mapbox.com/mapbox-gl-js/api/map/)
424
+ * @returns itself
401
425
*/
402
- attachMap ( map : mapboxgl . Map ) : MapLibre | Mapbox ;
426
+ attachMap ( map : maplibregl . Map | mapboxgl . Map ) : MapLibre ;
403
427
/**
404
428
* The default position of the control in the map.
405
429
*/
@@ -409,17 +433,20 @@ declare namespace JawgPlaces {
409
433
/**
410
434
* This class will help you to add or use search bar for geocoding with a Mapbox GL JS map.
411
435
*/
412
- class Mapbox extends MapLibre { }
436
+ class Mapbox extends MapLibre {
437
+ attachMap ( map : maplibregl . Map | mapboxgl . Map ) : Mapbox ;
438
+ }
413
439
414
440
/**
415
441
* This class will help you to add or use search bar for geocoding with a Leaflet map.
416
442
*/
417
443
class Leaflet extends AbstractPlaces {
418
444
constructor ( options : JawgPlacesLeafletOptions ) ;
419
445
/**
420
- * This is the function used by Leaflet when you add a { @link L.Control} .
446
+ * This is the function used by Leaflet when you add a [ L.Control](https://leafletjs.com/reference-1.7.1.html#control) .
421
447
* Adds the control to the given map.
422
- * @param map from Leaflet
448
+ * @param map from [Leaflet](https://leafletjs.com/reference-1.7.1.html#map-example)
449
+ * @returns the generated control container
423
450
*/
424
451
onAdd ( map : L . Map ) : void ;
425
452
/**
@@ -428,12 +455,13 @@ declare namespace JawgPlaces {
428
455
getPosition ( ) : string ;
429
456
/**
430
457
* Adds the control to the given map.
431
- * @param map from leaflet
458
+ * @param map from [Leaflet](https://leafletjs.com/reference-1.7.1.html#map-example)
432
459
*/
433
460
addTo ( map : L . Map ) : void ;
434
461
/**
435
- * When Jawg Places is not used as a control within your map, you will need to call this function.
436
- * @param map from Leaflet
462
+ * When Jawg Places **is not used** as a control within your map, you will need to call this function.
463
+ * @param map from [Leaflet](https://leafletjs.com/reference-1.7.1.html#map-example)
464
+ * @returns itself
437
465
*/
438
466
attachMap ( map : L . Map ) : Leaflet ;
439
467
}
0 commit comments