Send route request as POST

14 posts / 0 new
Last post
random_user_name
Send route request as POST

I can see LeafletJS is overwriting the default behaviour of MapQuest when calling the MQ.routing.directions().route() method but this forces the request to be of type GET which in my case requires very lengthy URL. I want to be able to send my data through a POST request. Is it possible?


MQBrianCoakley
You could hit the directions
You could hit the directions api directly with a post, but the plugin doesn't use a post. You can use an XMLHttpRequest or jQuery ajax. The biggest reason to use the route plugin is for drag routing. But with enough locations to justify a post over a get, I suspect that drag routing isn't that important. But I could be wrong.

random_user_name
I did manage to find a way

I did manage to find a way and send a POST request by looking deeper into leaflet's docs.

My biggest reason for that was been able to send a lot of route control points (about 140h+)


MQBrianCoakley
140,000 control points? I don
140,000 control points? I don't know how the router would handle that, but simpler is always better. Is there any checking to see if the control points are within the (potential) bounds of the route?

random_user_name
Well, I've tried with all

Well, I've tried with all sorts of points count but none of them work.

I am not even sure if Control Points are meant for the thing that I am looking for.


MQBrianCoakley
Control Points encourage or
Control Points encourage or discourage a route toward another point. If there are ways that are nice to go by (scenic, fun, etc), that would work well. If there are areas you would rather avoid (potholes, speed traps, etc), those would work. But if you HAVE to hit or miss that point, then use them as way points or avoids (avoidLinkIds).

random_user_name
Well, the thread might be

Well, the thread might be going off-topic so feel free to move the questions to another one.

I have made a screenshot with what I have currently (it would be easier for me to explain my goal). Here it is: 

The purple line is the route and the blue polylines is the network my route SHOULD try to follow as close as possible. Currently, when I try with passing the control points, the purple line (the route) stays the same. Any suggestions/algorithms I could use?


random_user_name
Here is the link to the image

Here is the link to the image (last post is not showing it for me):

http://s29.postimg.org/xx9nwer39/heavy_capture.png


MQBrianCoakley
That's very limiting. There
That's very limiting. There are no blue routes that hit Brussels. Can you post the request for the route with the control points that is not working as expected?   You might want to do the route first, then grab the bounding box from the route response, expand the bounds to some acceptable range to reduce the 140k control points to a more reasonable list to use in a second route request. You may also want to weight the control points closer to the first route heavier than the farther ones.

random_user_name
Here is the sample route

Here is the sample route request:

        directions.route({
            locations: latLngs,
            options: this._defaultDirectionOptions,
            routeControlPointCollection: [{
                lat: 51.173496,
                lng: 4.425789,
                weight: 0.1,
                radius: 20
            }]
        });

The hardcoded control point is really close the point A but it's still not altering the road. I've tried with countless combinations of weight/radius - still nothing.

I really like the idea about getting rid of the distant coords with a layer bounds but I first need to know that the control points feature is working.


MQBrianCoakley
Make sure to set the control
Make sure to set the control points inside the options.   dir.route({     locations: [         'Wheat Ridge, CO',         'Edgewater, CO'     ],     options: {"routeControlPointCollection":[{"lat":39.7615, "lng":-105.07195, "weight":0.1, "radius":0.5}]} });

MQBrianCoakley
I suspect having all of those
I suspect having all of those control points on either side of the route are going to cancel each other out. The control point is meant to nudge the route to a point, not force it on to acceptable roadways. It may work better in areas with fewer competing points. This looks like a good case for drag routing do the user can see the blue road segments and choose to change the route according to those.

random_user_name
Well that was a silly mistake

Well that was a silly mistake! Thanks!

I am still using alot of points and the app is doing just fine! 


MQBrianCoakley
That's awesome to hear.
That's awesome to hear. Thanks for the information.   You're not the first to put options outside the options node. I'm forwarding this information on to the team to make the documentation a little clearer.