
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
leaflet-geocoder-ban
Advanced tools
A simple Leaflet Plugin to add a geocoding control to your map, powered by the french [BAN](https://adresse.data.gouv.fr/) (Base Adresse Nationale) API. This API only covers French addresses.
A simple Leaflet Plugin to add a geocoding control to your map, powered by the french BAN (Base Adresse Nationale) API. This API only covers French addresses.
Check the online demo.
You can either:
npm install --save leaflet-geocoder-ban
or
First, load the leaflet files as usual.
Then, load the two leaflet-geocoder-ban files located in the src folder :
<script src="leaflet-geocoder-ban.js"></script>
<link rel="stylesheet" href="leaflet-geocoder-ban.css">
In your javascript code, create a Leaflet map:
var map = L.map('mapid').setView([45.853459, 2.349312], 6)
L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png", {
attribution: 'map attribution'}).addTo(map)
And add the geocoder:
var geocoder = L.geocoderBAN().addTo(map)
You can pass some options to the geocoderBAN()
function:
option | type | default | description |
---|---|---|---|
position | string | 'topleft' | Control position |
placeholder | string | 'adresse' | Placeholder of the text input |
resultsNumber | integer | 7 | Default number of address results suggested |
collapsed | boolean | true | Initial state of the control, collapsed or expanded |
autofocus | boolean | true | If the initial state of the control is expanded, choose wether the input is autofocused on page load |
serviceUrl | string | 'https://api-adresse.data.gouv.fr/search/' | API of the url |
minIntervalBetweenRequests | integer | 250 | delay in milliseconds between two API calls made by the geocoder |
var options = {
position: 'topright',
collapsed: 'false'
}
var geocoder = L.geocoderBAN(options).addTo(map)
When you select a result on the geocoder, it calls a default markGeocode
function. If you want to call a custom function, override it. It receives as argument the result given by the BAN API as described here
var geocoder = L.geocoderBAN({ collapsed: true }).addTo(map)
geocoder.markGeocode = function (feature) {
var latlng = [feature.geometry.coordinates[1], feature.geometry.coordinates[0]]
map.setView(latlng, 14)
var popup = L.popup()
.setLatLng(latlng
.setContent(feature.properties.label)
.openOn(map)
}
})
method | description |
---|---|
collapse() | collapses the geocoder |
expand() | expands the geocoder |
toggle() | toggles between expanded and collapsed state |
remove() | removes the geocoder |
var geocoder = L.geocoderBAN().addTo(map)
map.on('contextmenu', function () {
geocoder.toggle()
})
FAQs
A simple Leaflet Plugin to add a geocoding control to your map, powered by the french [BAN](https://adresse.data.gouv.fr/) (Base Adresse Nationale) API. This API only covers French addresses.
The npm package leaflet-geocoder-ban receives a total of 574 weekly downloads. As such, leaflet-geocoder-ban popularity was classified as not popular.
We found that leaflet-geocoder-ban demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.