2

Update: I have some gps locatiwaon points and i want to draw the path.I the way draw using polylines which dont follow road.I want to do "snap to road",so that i can improve the way path.

I referred this code to snap to road for the locations saved in array "snap_path_points"

I am getting path only for first 8 calls (limitation),below is code

var service = new google.maps.DirectionsService(), poly,snap_path=[];
              poly = new google.maps.Polyline({ map: map });
        for(j=0;j<snap_path_points.length-1;j++){
        service.route({
            origin: snap_path_points[j],
            destination: snap_path_points[j+1],
            travelMode: google.maps.DirectionsTravelMode.DRIVING
          }, function(result, status) {                
            if (status == google.maps.DirectionsStatus.OK) {
              snap_path = snap_path.concat(result.routes[0].overview_path);
              poly.setPath(snap_path);
            }        
          });
        }

I divided my locations to batches of 8 and tried the same (i.e if 24 points use 3 for loops ) but i am getting OVER_QUERY_LIMIT.

i wonder how its working with event listener here.

OVER_QUERY_LIMIT indicates the webpage has sent too many requests within the allowed time period.

Is there anyway to plot complete snap to road path with more than 8 points.

Community
  • 1
  • 1
nayab
  • 2,332
  • 1
  • 20
  • 34
  • What are you trying to do? What is the total number of points you are trying to "snap"? The DirectionsService, while it can be used to "snap" a few points to the nearest road is intended for getting directions (start, destination and up to 8 waypoints for free). – geocodezip Mar 26 '13 at 17:17
  • If it is only 24 points, and they aren't too close together, you might be able to do something like [this](http://www.geocodezip.com/v3_directions_multipleWayPts_CustomMrkrsB.html), combines the points as waypoints into fewer directions requests, however will still run into the query limit for hundreds of points. You will probably also run into issues with divided roads (if the point you provide is on the wrong side of the road, the resulting route will be non-optimal). – geocodezip Mar 26 '13 at 22:09
  • i tried dividing total 24 into 3 parts but i didnt use waypoints,they are near ,i got query limit. – nayab Mar 26 '13 at 22:50
  • Do you have a sample set of points? – geocodezip Mar 27 '13 at 03:48
  • @geocodezip http://pastebin.com/cucNp6BG – nayab Mar 27 '13 at 08:56
  • When I put those points into the algorithm, I get ZERO_RESULTS for some of the segments, not OVER_QUERY_LIMIT. I think you are going to have to do something more complicated (like get directions from the start to the finish, add waypoints from your data in an intelligent manner to make the path follow the correct roads), probably won't be easy to automate. – geocodezip Mar 27 '13 at 12:59
  • thanks for reply,how did you try,i tried dividing total points into batch of 10 locations(1-start,1-end,8-way points),but i got some queries OVER_QUERY_LIMIT.And if do directions from to finish it may or may not give path which follow my points. – nayab Mar 27 '13 at 13:21

1 Answers1

0

The problem is not that you sent too many points it is that you made too many request in the given time period. The snap to roads api states that:

Users of the standard API:

2,500 free requests per day and 10 requests per second

So if you sent more request than the limit described above, it is the reason why you are getting that error.

Balázs Vincze
  • 3,550
  • 5
  • 29
  • 60