From 0ddecc6e362032fb7c41e916d3ef95d04e259e15 Mon Sep 17 00:00:00 2001 From: Francis Chabouis Date: Fri, 2 Jun 2023 16:42:18 +0200 Subject: [PATCH] fix markGeocode example thanks to @2803media --- README.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 384d602..3d61e65 100644 --- a/README.md +++ b/README.md @@ -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