UNKNOWN_ERROR on 12 waypoints, not on 11 waypoints

580 views
Skip to first unread message

ipixel

unread,
Jan 20, 2010, 2:29:07 AM1/20/10
to Google Maps JavaScript API v3
Hi All

Getting an error on a test I'm doing on V3. It concerns the number of
waypoints I have between a 'origin' and 'destination' point. Example
page shown below:

http://www.starsofwa.com.au/googletest.html

This is basically taken from the example files for V3 and the error
occurs when there's 12 waypoints, all set to stopover 'true'. If I
remove any of the waypoints and knock it back to 11, then the map will
display the polyline and the DirectionsRenderer shows the step by step
instructions.

The maximum number of waypoints allowed is 23 plus the 'origin' and
'destination' according to the documentation - which I assume I would
see the error status of MAX_WAYPOINTS_EXCEEDED, but this is not the
case.

Code used as follows:

<script type="text/javascript">
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;

function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
var chicago = new google.maps.LatLng(-25.363882,120.27832);
var myOptions = {
zoom:5,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: chicago
}
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById
("directionsPanel"));

calcRoute()
}

function calcRoute() {
var request = {
origin: "Perth, WA",
destination: "Albany WA",
waypoints: [
{
location: new google.maps.LatLng
(-32.304291378,115.702241063),
stopover:true
},{
location: new google.maps.LatLng
(-33.319734803,115.643162727),
stopover:true
},{
location: new google.maps.LatLng
(-33.644277591,115.344353914),
stopover:true
},{
location: new google.maps.LatLng
(-33.642241142,115.034279823),
stopover:true
},{
location: new google.maps.LatLng
(-33.698761474,115.016212463),
stopover:true
},{
location: new google.maps.LatLng
(-33.966204552,115.070800781),
stopover:true
},{
location: new google.maps.LatLng
(-34.837547610,116.004209518),
stopover:true
},{
location: new google.maps.LatLng
(-34.454518655,116.049442291),
stopover:true
},{
location: new google.maps.LatLng
(-34.444556637,116.034979820),
stopover:true
},{
location: new google.maps.LatLng
(-34.985987621,116.882944107),
stopover:true
},{
location: new google.maps.LatLng
(-35.035478228,117.919000983),
stopover:true
},{
location: new google.maps.LatLng
(-35.095192592,117.959089279),
stopover:true
}],
provideTripAlternatives: false,
travelMode: google.maps.DirectionsTravelMode.DRIVING,
unitSystem: google.maps.DirectionsUnitSystem.METRIC
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
} else {
alert(status)
}
});
}
</script>

Could it be the use of the LatLng() function within the setup of the
waypoints array?

Cheers
Brendan

Ben Appleton

unread,
Jan 20, 2010, 3:08:56 AM1/20/10
to google-map...@googlegroups.com
Hi Brendan,

Firebug reports "414 Request-URI Too Large".  The API has generated a url that is too long to send to Google's directions service.  I'll file a bug.

Cheers
Ben

--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.




ipixel

unread,
Jan 20, 2010, 4:32:07 AM1/20/10
to Google Maps JavaScript API v3
Thanks Ben, is there anything that I can do to alleviate the problem
from my end do you think?

Cheers
Brendan

Ben Appleton

unread,
Jan 20, 2010, 5:10:50 AM1/20/10
to google-map...@googlegroups.com
I'd suggest splitting the waypoints into multiple queries.  So if you had 15 waypoints, display directions from 1 through 10, then from 10 through 15.

ipixel

unread,
Jan 20, 2010, 5:46:34 AM1/20/10
to Google Maps JavaScript API v3
Hmmm, will give that a go. Interesting though that the max is 23
though. I assume that this is a bug though, so hopefully it will be
rectified soon. Splitting waypoints will become a tedious proposition
otherwise.

Payden

unread,
Mar 19, 2010, 11:37:11 AM3/19/10
to Google Maps JavaScript API v3
Has there been anymore developments with this? Or is our only option
to split the routing in two or three parts?

Ben Appleton

unread,
Mar 19, 2010, 5:51:28 PM3/19/10
to google-map...@googlegroups.com

We're working on it but your best short term option is simply to split the route.

On 20 Mar 2010 03:37, "Payden" <yoyo...@gmail.com> wrote:

Has there been anymore developments with this?  Or is our only option
to split the routing in two or three parts?


On Jan 20, 6:46 am, ipixel <s13sillb...@gmail.com> wrote:

> Hmmm, will give that a go. Interesting ...

--

You received this message because you are subscribed to the Google Groups "Google Maps JavaScript AP...

bratliff

unread,
Mar 19, 2010, 6:05:02 PM3/19/10
to Google Maps JavaScript API v3

V3 uses a very long GET URL compared to V2.

Look at:

http://www.polyarc.us/routes

to see what is happening.

Different browsers have different GET URL limitations. Internet
Explorer truncates the URL sent to the server at something like 2048
characters. An incomplete URL will be missing a proper "token" even
if it is otherwise complete. Without a valid "token" if is considered
an invalid request.

Payden

unread,
Mar 22, 2010, 9:01:02 AM3/22/10
to Google Maps JavaScript API v3
Any possibility of google changing the API to allow POST'ing data to
the directions service instead?

bratliff

unread,
Mar 22, 2010, 12:15:38 PM3/22/10
to Google Maps JavaScript API v3

On Mar 22, 1:01 pm, Payden <yoyoja...@gmail.com> wrote:
> Any possibility of google changing the API to allow POST'ing data to
> the directions service instead?

To avoid cross-domain access restrictions, it must be a JS file loaded
with a SCRIPT element. An application cannot POST to Google's servers
without a proxy.

Reply all
Reply to author
Forward
0 new messages