perliedman / leaflet-routing-machine

Control for routing in Leaflet
https://www.liedman.net/leaflet-routing-machine/
Other
1.06k stars 347 forks source link

How to integrate leaflet routing machine with mapbox / google map #657

Open aliceevra opened 2 years ago

aliceevra commented 2 years ago

I'm using leaflet routing machine with geocoder photon , I want to change search with geocoder google map or mapbox . How I can do this, any idea please . Thank you in advance

This is my example : https://jsfiddle.net/Aminali/kLs34ef8/7/

curtisy1 commented 2 years ago

LRM itself relies on the awesome Leaflet Control Geocoder plugin to offer geocoding. This plugin has a wide variety of available geocoders that you could use. If you want to use mapbox instead of Photon, all you have to do is change

L.Control.Geocoder.photon()

to

L.Control.Geocoder.mapbox({
    apiKey: 'your api key here'
})