Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read the global configuration, not the local one #456

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

efranqueiro
Copy link

Local options contains the waypoint list, but geometryOnly is in the global options object

Copy link
Owner

@perliedman perliedman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
it's been a while since I worked with this myself, but as far as I remember, geometryOnly is an option passed directly to the route method, not set on the router. See for example

geometryOnly: true,
, which I think is the primary use case for this option. Using this.options instead would mean that the geometryOnly would be discarded in this call.

Do you agree? Which problem are you trying to solve with this PR?

@efranqueiro
Copy link
Author

efranqueiro commented Feb 7, 2018

Hi.
What I'm trying to do is not show the "legend", as seen here

image

This is the code I'm using

            var directions_provider = L.Routing.control({
                waypoints: waypoints,
                router: new L.Routing.TomTom(options.routing_apikey, options),
                // geometryOnly: true,     // don't show the legend
                lineOptions: {
                    styles: [
                        {color: 'black', opacity: 0.15, weight: 9},
                        {color: 'white', opacity: 0.8, weight: 6},
                        {color: 'blue', opacity: 0.5, weight: 2}
                    ]
                }
            });
            directions_provider.addTo(options.map);     // before calling route()

            directions_provider.route(waypoints, function(context, result) {
                if (result && success_callback) {
                    success_callback(...);
                }
            }, {}, { geometryOnly: true });

If I pass geometryOnly: true in the options to the route() method, I get the image above, which is not what I want.
With this change, it doesn't show the legend, as desired.
With the code above, the option is being ignored.

Perhaps I'm mistaken in the way to hide the legend?

Thanks!

@perliedman
Copy link
Owner

Alright, it's interesting to note that you can achieve that using geometryOnly this way; I wasn't aware of that.

If I understand correctly, you should look at #20 for techniques to hide the itinerary.

@efranqueiro
Copy link
Author

I tried hide(), but it hides the itinerary and also the route and waypoints.
Then I tried the CSS approach by putting it in a file and including that in my html (I tried before and after the Leaflet CSS). But that didn't work either. Is that the way to use it?
So, for now, geometryOnly still works for me.

In any case, I tried passing it as you suggested and it didn't work, which takes me back to this PR :)

@perliedman
Copy link
Owner

The thing is, as it is now, this PR breaks the original purpose of the geometryOnly option, since it will be disregarded when passed to the route method. So it will not fly.

I know hiding the itinerary isn't ideally implemented as it is now, but I don't see this PR as the way forward to improve that.

Using a CSS rule is probably the easiest, and it definitely does work as long as you put the rule in the correct place and use the correct specificity.

Other than that, improving the functionality offered by hide would be the best way to improve the situation.

@efranqueiro
Copy link
Author

Agreed that this is not the right way to do what I want, So I worked around that in my code.

For the CSS approach, what would the correct place be?

In my tests, passing geometryOnly in the options for the route() method doesn't seem to work. So unless I'm mistaken, currently, there's no way to pass that option. So either we pass it in the constructor, with this PR, or the other scenario should be fixed. Perhaps just doing if (options.geometryOnly || this.options.geometryOnly) would be a suitable workaround?

@Lweaver5051
Copy link

Hello everyone,
I have made a post but not getting any responses. Im new to leaflet and dont know whats going on or why. I believe I added everything the documents say to add but I'm still getting the error.

_

<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>_

import L from 'leaflet';

ERROR TypeError: Cannot read property 'control' of undefined

My Code where --> var polylineRouteB = L.Routing.control({**

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants