How to use own Geocoder Service instead of L.Control.Geocoder.nominatim().
dev1ninja opened this issue · 2 comments
dev1ninja commented
Hi there,
I'm running my own Geocoder Service(I installed based on installation guide)
It is Geo.mygovernmentonline.org.
And here is my code.
L.Control.geocoder().addTo(map);
var routeControl = L.Routing.control({
waypoints: [],
serviceUrl: 'https://osrm.mgoconnect.org/route/v1',
geocoder: L.Control.Geocoder.nominatim(),
routeWhileDragging: true,
}).addTo(map);
var geocoder = L.Control.Geocoder.nominatim();
geocoder.geocode(address[i][0], function (results) {
if (results[0] !== undefined) {
resolve(L.latLng(results[0].properties.lat, results[0].properties.lon));
} else {
resolve()
}
})
As I mentioned in Title, now I would like to use my own Geocoder Service instead of geocoder: L.Control.Geocoder.nominatim()
, var geocoder = L.Control.Geocoder.nominatim()
Please help me.
Thank you!
curtisy1 commented
Hey there,
you have two options for this one which both more or less do the same thing.
- You can implement your own geocoder, taking the nominatim one as a guide
- extend the nominatim one via
class YourGeocoder extends L.Control.Geocoder.Nominatim {
// override the geocode method here
}
- depending on what your geocoding server does, you might also use an existing geocoder and replace the serviceUrl
const geocoder = L.Control.Geocoder.nominatim({ serviceUrl: "Geo.mygovernmentonline.org" });
dev1ninja commented
I understand.
This is very helpful.
Thank you!