Skip to content

Commit

Permalink
fix markGeocode example
Browse files Browse the repository at this point in the history
thanks to @2803media
  • Loading branch information
fchabouis authored Jun 2, 2023
1 parent 9a690ad commit 0ddecc6
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,19 @@ 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](https://adresse.data.gouv.fr/api-doc/adresse)

```javascript
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)
}
})
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)
}
```

# Methods
Expand Down

0 comments on commit 0ddecc6

Please sign in to comment.