{"id":27019317,"url":"https://github.com/opencagedata/leaflet-opencage-geocoding","last_synced_at":"2026-01-11T17:05:15.132Z","repository":{"id":16139202,"uuid":"18884576","full_name":"OpenCageData/leaflet-opencage-geocoding","owner":"OpenCageData","description":"A Leaflet geocoding control that uses the OpenCage geocoding API","archived":false,"fork":false,"pushed_at":"2023-01-21T22:11:53.000Z","size":316,"stargazers_count":22,"open_issues_count":0,"forks_count":11,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-05-02T04:34:29.793Z","etag":null,"topics":["geocoder","geocoding","leaflet","opencage","opencage-data"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenCageData.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2014-04-17T16:03:40.000Z","updated_at":"2023-09-30T18:55:03.000Z","dependencies_parsed_at":"2023-02-12T13:01:18.372Z","dependency_job_id":null,"html_url":"https://github.com/OpenCageData/leaflet-opencage-geocoding","commit_stats":null,"previous_names":["opencagedata/leaflet-opencage-search","lokku/leaflet-opencage-search"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenCageData%2Fleaflet-opencage-geocoding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenCageData%2Fleaflet-opencage-geocoding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenCageData%2Fleaflet-opencage-geocoding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenCageData%2Fleaflet-opencage-geocoding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenCageData","download_url":"https://codeload.github.com/OpenCageData/leaflet-opencage-geocoding/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247219604,"owners_count":20903478,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geocoder","geocoding","leaflet","opencage","opencage-data"],"created_at":"2025-04-04T17:27:11.701Z","updated_at":"2026-01-11T17:05:15.127Z","avatar_url":"https://github.com/OpenCageData.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenCage Geocoding Control for Leaflet\n\nA [Leaflet](http://leafletjs.com/) geocoding control that uses OpenCage's [geocoding API](https://opencagedata.com).\n\nCheck out a demo page in `/demo`. Or take a look at the live [demo](https://opencagedata.com/tutorials/geocode-in-leaflet).\n\nNote: if you want location autosuggest then what you want is [OpenCage's geosearch](https://opencagedata.com/geosearch), not geocoding.\n\n## Dependencies\n\nLeaflet version 0.7+ to 1.9.x\n\nFor Leaflet version 2: check the [release branch v3.x](https://github.com/OpenCageData/leaflet-opencage-geocoding/tree/release/v3.0.0)\n\n## Breaking changes\n\nStarting with version 2.1, Bower is no longer supported. The package is now published on npm in both UMD and ESM formats.\n\n## Installation\n\n### Via npm\n\n```bash\nnpm install leaflet-opencage-geocoding\n```\n\nThe package includes both UMD and ESM builds, which you can import based on your project setup:\n\n```javascript\n// ESM\nimport 'leaflet-opencage-geocoding';\n\n// CommonJS\nrequire('leaflet-opencage-geocoding');\n```\n\n### Via CDN (for vanilla JS/HTML projects)\n\nFor classic HTML projects, you can use the CDN:\n\n```html\n\u003clink\n  rel=\"stylesheet\"\n  href=\"https://cdn.jsdelivr.net/gh/opencagedata/leaflet-opencage-geocoding@v2.1.0/dist/css/L.Control.OpenCageGeocoding.min.css\"\n/\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/opencagedata/leaflet-opencage-geocoding@v2.1.0/dist/js/L.Control.OpenCageGeocoding.min.js\"\u003e\u003c/script\u003e\n```\n\n### Other options\n\n- Clone from GitHub: `git@github.com:opencagedata/leaflet-opencage-geocoding.git`\n- Download a [zip or tarball archive](https://github.com/opencagedata/leaflet-opencage-geocoding/tags)\n\n## Usage\n\nLoad the plugin's CSS and JavaScript files:\n\n```HTML\n\u003clink rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/gh/opencagedata/leaflet-opencage-geocoding@v2.1.0/dist/css/L.Control.OpenCageGeocoding.min.css\" /\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/opencagedata/leaflet-opencage-geocoding@v2.1.0/dist/js/L.Control.OpenCageGeocoding.min.js\"\u003e\u003c/script\u003e\n```\n\nAdd the plugin's control to an `L.Map` instance:\n\n```javascript\nvar map = L.map('map').setView([51.52255, -0.10249], 13);\nvar options = {\n  key: 'your-api-key-here',\n  limit: 10,\n};\nvar control = L.Control.openCageGeocoding(options).addTo(map);\nL.tileLayer('http://tile.osm.org/{z}/{x}/{y}.png', {\n  attribution:\n    '\u0026copy; \u003ca href=\"http://osm.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors',\n}).addTo(map);\n```\n\n## Customizing\n\nBy default, when a geocoding result is found, the control will centre the map on it and place a marker\nat its location. This can be customised by overwriting the control's markGeocode function to perform\nany action desired.\n\nFor example:\n\n```javascript\nvar control = L.Control.openCageGeocoding(options).addTo(map);\n\ncontrol.markGeocode = function (result) {\n  var bbox = result.bbox;\n  L.polygon([\n    bbox.getSouthEast(),\n    bbox.getNorthEast(),\n    bbox.getNorthWest(),\n    bbox.getSouthWest(),\n  ]).addTo(map);\n};\n```\n\nThis will add a polygon representing the result's bounding box when a result is selected.\n\n## Options\n\nYou can overwrite the following options, for example, to translate.\n\n```javascript\nvar options = {\n    key: '', // your OpenCage API key\n    limit: 5 // number of results to be displayed\n    position: 'topright',\n    placeholder: 'Search...', // the text in the empty search box\n    errorMessage: 'Nothing found.',\n    showResultIcons: false,\n    collapsed: true,\n    expand: 'click',\n    addResultToMap: true, // if a map marker should be added after the user clicks a result\n    onResultClick: undefined, // callback with result as first parameter\n    resultExtension: {\n        geohash: \"annotations.geohash\",\n        what3words: \"annotations.what3words\",\n        addressComponents: \"components\"\n    } //if additional attributes from OpenCage search API should be added to the result\n};\n\nvar control = L.Control.openCageGeocoding(options).addTo(map);\n\n```\n\n## Contributing\n\nSee `CONTRIBUTING.md` file.\n\n## License\n\nSee `LICENSE` file.\n\n### Who is OpenCage GmbH?\n\n\u003ca href=\"https://opencagedata.com\"\u003e\u003cimg src=\"opencage_logo_300_150.png\"\u003e\u003c/a\u003e\n\nWe run the [OpenCage Geocoder](https://opencagedata.com). Learn more [about us](https://opencagedata.com/about).\n\nWe also run [Geomob](https://thegeomob.com), a series of regular meetups for location based service creators, where we do our best to highlight geoinnovation. If you like geo stuff, you will probably enjoy [the Geomob podcast](https://thegeomob.com/podcast/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopencagedata%2Fleaflet-opencage-geocoding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopencagedata%2Fleaflet-opencage-geocoding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopencagedata%2Fleaflet-opencage-geocoding/lists"}