Page 1 of 1
Routing Settings
Posted: 21 Jan 2020, 12:38
by Reddar
Hello,
I would like to change the router and switch to Mapbox.
I've tested a lot of parameters but i did'nt succeed.
Last try :
I always get the following message in the console :
leaflet-routing-machine.min.js:13
You are using OSRM's demo server. Please note that it is **NOT SUITABLE FOR PRODUCTION USE**.
Refer to the demo server's usage policy: https://github.com/Project-OSRM/osrm-ba ... age-policy
To change, set the serviceUrl option.
Please do not report issues with this server to neither Leaflet Routing Machine or OSRM - it's for
demo only, and will sometimes not be available, or work in unexpected ways.
Please set up your own OSRM server, or use a paid service provider for production.
Thank's for your help.
Re: Routing Settings
Posted: 26 Jan 2020, 21:05
by Jan
Hi, can I see the site where this occurs? To see which link is used to connect to Mapbox.
Should be:
... api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token= ...
Jan
Re: Routing Settings
Posted: 27 Oct 2020, 09:49
by Reddar
Hi Jan,
I am reactivating this item. Same issue with latest version 3.0.8.
I have remove this option from the production site.
My test site is off line.
How can i see the link used to connect to Mapbox ?
Thanks
Re: Routing Settings
Posted: 30 Oct 2020, 18:17
by Reddar
Hi Jan,
I found an issue in the phocamapsmaposm.php file. It seems that the Router parameters are not well managed.
I am not a php pro at all, so i have made a modification as i could, fulfilling my needs.
Instead of
Code: Select all
if ($this->routerserviceurl == 'https://api.mapbox.com/directions/v5') {
// DEBUG DEMO - default address of leaflet-routing-machine to debug
} else if ($this->routerserviceurl != '') {
$o[] = ' routerserviceurl: \''.$this->routerserviceurl.'\',';
} else if ($this->osm_map_type == 'mapbox' && $this->maprouterapikey != '') {
$o[] = ' router: L.Routing.mapbox(\''.PhocaMapsHelper::filterValue($this->maprouterapikey).'\'),';
} else {
$o[] = array();
$o[] = 'console.log(\'Routing Error: No router or service url set\')';
$this->output[] = implode("\n", $o);
return true;
}[/size]
I wrote
Code: Select all
if ($this->routerserviceurl == 'https://api.mapbox.com/directions/v5') {
// DEBUG DEMO - default address of leaflet-routing-machine to debug
} else if ($this->routerserviceurl != "'' && $this->maprouterapikey != ''"){
$o[] = ' routerserviceurl: \''.$this->routerserviceurl.'\',';
$o[] = ' router: L.Routing.mapbox(\''.PhocaMapsHelper::filterValue($this->maprouterapikey).'\',{language: \''.PhocaMapsHelper::filterValue($language, 'text').'\'}),';
That's enough to get a french Mapbox routing.
Of course i'm sure there is a clever way to manage all the different router parameters !
Re: Routing Settings
Posted: 02 Nov 2020, 19:48
by Jan
Hi, thank you for the info, I will take a look at it, there needs to be done some additional conditions but if I understand it correctly, even the mapbox will accept reouterserviceurl parameter.
Thank you, Jan
Re: Routing Settings
Posted: 02 Nov 2020, 19:51
by Jan
Please test this code and let me know:
Code: Select all
if ($this->routerserviceurl == 'https://api.mapbox.com/directions/v5') {
// DEBUG DEMO - default address of leaflet-routing-machine to debug
} else if ($this->osm_map_type == 'mapbox' && $this->maprouterapikey != '' && $this->routerserviceurl != '') {
$o[] = ' routerserviceurl: \''.$this->routerserviceurl.'\',';
$o[] = ' router: L.Routing.mapbox(\''.PhocaMapsHelper::filterValue($this->maprouterapikey).'\'),';
} else if ($this->osm_map_type == 'mapbox' && $this->maprouterapikey != '') {
$o[] = ' router: L.Routing.mapbox(\''.PhocaMapsHelper::filterValue($this->maprouterapikey).'\'),';
} else if ($this->routerserviceurl != '') {
$o[] = ' routerserviceurl: \''.$this->routerserviceurl.'\',';
} else {
$o[] = array();
$o[] = 'console.log(\'Routing Error: No router or service url set\')';
$this->output[] = implode("\n", $o);
return true;
}
Jan
Re: Routing Settings
Posted: 03 Nov 2020, 12:02
by Reddar
Hi Jan,
I am using mapbox routing with an openstreet french map. When i try to use the mapbox map i have no map and no error message.
So your code doesn't work in that case because of
if ($this->routerserviceurl == '
https://api.mapbox.com/directions/v5') {
// DEBUG DEMO - default address of leaflet-routing-machine to debug
and because : if ($this->osm_map_type == 'mapbox' .....
And you don't take into account the language parameter.
Regards
Re: Routing Settings
Posted: 04 Nov 2020, 21:44
by Jan
Hi, yes, the language is missing:
See:
Code: Select all
if ($this->routerserviceurl == 'https://api.mapbox.com/directions/v5') {
// DEBUG DEMO - default address of leaflet-routing-machine to debug
} else if ($this->osm_map_type == 'mapbox' && $this->maprouterapikey != '' && $this->routerserviceurl != '') {
$o[] = ' routerserviceurl: \''.$this->routerserviceurl.'\',';
//$o[] = ' router: L.Routing.mapbox(\''.PhocaMapsHelper::filterValue($this->maprouterapikey).'\'),';
$o[] = ' router: L.Routing.mapbox(\''.PhocaMapsHelper::filterValue($this->maprouterapikey).'\',{language: \''.PhocaMapsHelper::filterValue($language, 'text').'\'}),';
} else if ($this->osm_map_type == 'mapbox' && $this->maprouterapikey != '') {
$o[] = ' router: L.Routing.mapbox(\''.PhocaMapsHelper::filterValue($this->maprouterapikey).'\'),';
} else if ($this->routerserviceurl != '') {
$o[] = ' routerserviceurl: \''.$this->routerserviceurl.'\',';
} else {
$o[] = array();
$o[] = 'console.log(\'Routing Error: No router or service url set\')';
$this->output[] = implode("\n", $o);
return true;
}
Now it should work, the only one addition to your code is to check the "mapbox" service, so other services are not negatively influneced (it is not possible to set mapbox routing generally for all other services):
- Your code:
Code: Select all
else if ($this->routerserviceurl != "'' && $this->maprouterapikey != ''"){
- The new code:
Code: Select all
else if ($this->osm_map_type == 'mapbox' && $this->maprouterapikey != '' && $this->routerserviceurl != '') {
So maybe I don't understand it correctly but are you displaying the map with another method than using the routing?
Map not rendered by Mapbox, but Routing yes?
Because then in such way it cannot be used generally becasue this will render mapbox routing for users who don't use mapbox ( if ($this->routerserviceurl != "'' && $this->maprouterapikey != ''") - no check for maptype)
Re: Routing Settings
Posted: 11 Nov 2020, 21:00
by Reddar
Hi,
The main point is that i do not use Mapbox map. I use an Openstreet french map . And i use the mapbox routing. See my parameters below.

Re: Routing Settings
Posted: 12 Nov 2020, 20:42
by Jan
OK, now I understand, I will try to take a look at it.
Jan