osrm-frontend icon indicating copy to clipboard operation
osrm-frontend copied to clipboard

osrm-frontend.js options need documenting

Open mvl22 opened this issue 9 years ago • 2 comments

I can't seem to find any documentation on the options in osrm-frontend.js, and several things are unclear:

  1. layer and baselayer seem to be partially duplicated, but the meaning of each is unclear, and the ordering given in either does not reflect what appears online.

  2. It is unclear how to set the default tile layer. Setting this in defaultView.layer doesn't seem to take effect, even after a rebuild.

  3. services implies a set of definitions, but none ever appears in the interface as far as I can tell.

  4. overlay refers to small_components (whose purpose is not documented) but it is not clear if no overlays (again, not clear what these are intended to be) are wanted.

Would someone kindly be add some comments to the template of this file, so that these become clear?

(In the meanwhile, if anyone can clarify the above on this thread that would also be useful!)

mvl22 avatar Jul 28 '16 12:07 mvl22

To answer my own question 3, the code has:

serviceUrl: leafletOptions.services[0].path

which seems to show that only the first is ever used, if there is more than one.

mvl22 avatar Nov 01 '16 17:11 mvl22

it's confusing because there is different JS running in the public demo instance at http://map.project-osrm.org . There the different services are available at the bottom left of where you type the address. I assume these are extra entries in the services array in leaflet-options.js. If you look in dev tools, on line 1500 inside the onAdd function, it's adding the services like this:

     for (var s = 0, d = this.options.services.length; s < d; s++) {
                                    var l;
                                    l = n.DomUtil.create("option", "", a),
                                    l.setAttribute("value", "" + s),
                                    l.innerHTML = this.options.services[s].label
                                }
                                n.DomEvent.addListener(a, "change", function() {
                                    a.selectedIndex >= 0 && a.selectedIndex < o.length && (n.Util.setOptions(r, 
                                       {
                                        serviceUrl: o[a.selectedIndex].path,
                                        fixspeed: o[a.selectedIndex].fixspeed
                                    }),
                                    this.setWaypoints(this.getWaypoints()))
                                }, this)

None of that code appears anywhere in the src/ folder javascript inside the git repo here, but it's running on the public demo instance. It's seems like it's two different versions of the code.

damienvancouver avatar Aug 21 '20 04:08 damienvancouver