Skip to content

Conversation

@anthonykaram
Copy link

Summary

Fixes a bug when using sourceData with Leaflet.Control.Search where valid results
are returned by the data source, but the control always reports "Location not found".

This happens due to an incorrect invocation of formatData when sourceData is used.


Reproduction

  1. Configure L.Control.Search with sourceData returning an array of result objects
    (e.g. { title, lat, lon })
  2. Type a known-valid query (e.g. "Paris")
  3. Tooltip suggestions appear
  4. Submitting the search results in "Location not found"

A minimal repro is included in:

examples/simple-sourceData-bug.html


Fix

Ensure formatData is invoked consistently when using sourceData, so that
_recordsCache is populated with the expected key → LatLng mapping.

This aligns sourceData behavior with url and layer search modes.


Files changed

  • src/leaflet-search.js
  • dist/leaflet-search.src.js
  • examples/simple-sourceData-bug.html (repro + verification)

Notes

  • Minified files were not updated.
  • Verified manually that the repro page works correctly after the fix.

@anthonykaram
Copy link
Author

Confirmed repro: examples/simple-sourceData-bug.html shows suggestions but “Location not found” on submit before fix; after fix it navigates correctly. Minified artifacts not regenerated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant