Routing Settings

Phoca Maps - displaying maps in Joomla! CMS
Reddar
Phoca Enthusiast
Phoca Enthusiast
Posts: 58
Joined: 29 Mar 2019, 23:33

Routing Settings

Post 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.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47810
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Routing Settings

Post 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
If you find Phoca extensions useful, please support the project
Reddar
Phoca Enthusiast
Phoca Enthusiast
Posts: 58
Joined: 29 Mar 2019, 23:33

Re: Routing Settings

Post 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
Reddar
Phoca Enthusiast
Phoca Enthusiast
Posts: 58
Joined: 29 Mar 2019, 23:33

Re: Routing Settings

Post 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 !
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47810
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Routing Settings

Post 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
If you find Phoca extensions useful, please support the project
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47810
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Routing Settings

Post 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
If you find Phoca extensions useful, please support the project
Reddar
Phoca Enthusiast
Phoca Enthusiast
Posts: 58
Joined: 29 Mar 2019, 23:33

Re: Routing Settings

Post 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
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47810
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Routing Settings

Post 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)
If you find Phoca extensions useful, please support the project
Reddar
Phoca Enthusiast
Phoca Enthusiast
Posts: 58
Joined: 29 Mar 2019, 23:33

Re: Routing Settings

Post 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.
Image
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47810
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Routing Settings

Post by Jan »

OK, now I understand, I will try to take a look at it.

Jan
If you find Phoca extensions useful, please support the project
Post Reply