I am using google maps api to calculate the number of miles my company\'s vehicles travel in each state over a period of time. For trips taken over the period, the user wil
Looking at the directions text in the panel, it looks like the text "Entering " appears in the steps that cross state boundaries.
http://www.geocodezip.com/v3_example_geo2.asp?addr1=New%20York,NY&addr2=Washington,%20DC&geocode=1&geocode=2
(this is not documented, so might stop working)
You could also find the intersection of the Directions polyline with a set of state polygons.
If you have 1000 elements in your path array and you are binary searching (instead of iterating), it should only take 12 calls to LatLng to determine where the path crosses the border.
What sort of feedback do you get when you go over quota? If it's an exception return, you could always do the 3.5 second wait only when you receive the quota pushback.
Personally, I would use GeoNames for something like this, not Google.
With Geonames, you will most likely run into quota problems as with Google, however, there's a big difference ... Geonames allows you to download various datasets so you can provide your own self-hosted geo-service(s) ... sans quota.
I've never needed to do this so can only advise you to rummage round in the Geonames site for instructions.
In principle, you need to :
By doing the hard math server-side and returning bundled results, you will only need to make one HTTP request (per company vehicle).
Of course, the server will need the appropriate lat/lng path data but from what you say in the question, that's already server-side, so no need for it to be downloaded to the client just to be resent in the request.
Interesting project. From the outset, you will need to think about your testing/verification strategy.
Sorry I can't be of more help but maybe this gives you a way ahead.