Does calling google.maps.LatLng() contribute to any API limits? - javascript

I see the limits chart on Google Maps API and it says a limit of 25,000 map loads per day.
https://developers.google.com/maps/documentation/javascript/usage#premium-usage-limits
But what about calling google.maps.LatLng()?
https://developers.google.com/maps/documentation/javascript/reference#LatLng
I assume its just a function so there is no limit, but I want to make sure before I put my code into production.

Thanks to #user2263572 for his comment. For anyone wondering how to see requests going out, go to:
Right-click > Inspect Element > Network
And from here you can observe the network traffic!

Related

Where can I view the secondary rate limit of GitHub REST api?

I'm trying to create something with GitHub's REST api using Octokit, but I'm having trouble dealing with their secondary rate limit, I wonder where can I view this secondary rate limit, or know exactly how they work? The documentation seems to be very vague about the inner workings of this said secondary rate limit.
The rate limits can be viewed using the endpoint below, but it does not include the secondary rate limit.
await octokit.request('GET /rate_limit', {})
Also the documentation only provides best practices to avoid this secondary rate limit, but even this does not help.
Specifically I'm constantly using their follow a user endpoint every 2 seconds and doing a 5 minute sleep after 24 requests, but at some point I'm still hitting this secondary rate limit.
await octokit.request('PUT /user/following/{username}', {
username: 'USERNAME'
})
At this point, the only solution that I can think of is to slow down even further with the requests, but that is not optimal.
I wonder If GitHub has a way to view this secondary rate limit so I can deal with it programmatically, or on a much clearer way?
You can see secondary rate limits configured on a on-premise GHE (GitHub for Enterprise) instance.
Type limits for:
Total Requests,
CPU Limit, and
CPU Limit for Searching,
or accept the pre-filled default limits.
But even that instance does not have an exposed API to configure those elements: web page interface only.

Google maps javascript DirectionRenderers limit

I am looking to display many routes on one instance of map, each route with different color. For it I created an array of DirectionsRenderer objects and assigning separate DirectionsRenderer for each route.
The problem is GoogleMap component displays only first 10 DirectionsRenderer, I was not able to find any info on this limitation in google developers website. Is there any way to use more than 10 DirectionsRenderers at same time?
Thanks for help in advance.
Just to add to what #geocodezip said:
"I was not able to find any info on this limitation in google developers website."
Here you go:
Usage limits and
policies
-Up to 8 waypoints per request, plus the origin and destination. // 10 overall
-50 requests per second, calculated as the sum of client-side and server-side queries.
-2,500 free requests per day, calculated as the sum of client-side and server-side queries; enable billing to access higher daily quotas,
billed at $0.50 USD / 1000 additional requests, up to 100,000 requests
daily.

Google doesn't tell me which waypoint is wrong (Javascript API)

When Google returns a NOT_FOUND response to a direction request with waypoints, the documentation says
NOT_FOUND indicates at least one of the locations specified in the requests
origin, destination, or waypoints could not be geocoded.
But it doesn't tell me which one is invalid...
I realise I could then attempt to geocode each address individually to find the bad address, but that is wasting a lot of geocoding requests, given I have about 20 waypoints, and given Google could just tell me which one failed...
Is there a way to do this?
My fallback is to geocode the addresses before I save them, however I'd prefer not to do this, if I can get google to tell me which waypoint failed.
Normally, the response comes back with warnings, and I thought the bad address may come back in that, however I think that only happens if a route can be built in the first place.
Warning items are intended to display information when a route has been found, you are right. For example, it is telling that the walking directions mode results are in beta.
Sample: http://maps.googleapis.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charle,MA&mode=walking
For the problem you depicted (waypoint is not found), the response of the webservice is really short. Sample call with a non-working waypoint:
http://maps.googleapis.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Chle,MA
Result:
{
"routes" : [],
"status" : "ZERO_RESULTS"
}
The google maps Directions API is not currently helping for your case, and you also cannot try to geocode all your waypoint at once. Furthermore, the geocode api will throw an error if you exceed 5 simultaneous requests, so you initial workaround idea may be limited.
As a workaround (but not perfect, as the results between this service and gmaps service can be different), you could try to use other geocoding services, such as the one provided by OpenStreetMap: http://wiki.openstreetmap.org/wiki/Nominatim#Search
You still have to do it one-by-one, but you won't be getting a "query limit exceeded" error.

Meteor.jd, realtime latency with complex pusblish/subscribe rules?

I'm playing with realtime whiteboards with meteor. My first attempt was working very well, if you open 2 browsers and draw in one of them, the other one updates in a few milliseconds ( http://pen.meteor.com/stackoverflow )
Now, my second project, is to make an infinite realtime whiteboard. The main thing that changes now, is that all lines are grouped by zones, and the viewer only subscribe to the lines in the visible zones. And now there is a dealy of 5 seconds (!) when you do something in one browser to see it happen in the other one ( http://carve.meteor.com/love ).
I've tried to add indexes in the mongo database for the fields determining the zones.
I've tried updating the Collection only for a full line (and not each time I push a new point like i my first project).
I've tried adding a timeout not to subscribe too often when scrolling or zooming the board.
Nothing changes, always a 5 seconds delay.
I don't have this delay when working locally.
Here is the piece of code responsible for subscribing to the lines you the visible area :
subscribeTimeout=false;
Deps.autorun(function () {
var vT=Session.get("visible_tiles");
var board_key=Session.get("board_key");
if (subscribeTimeout) Meteor.clearTimeout(subscribeTimeout);
subscribeTimeout=Meteor.setTimeout(subscribeLines, 500);
});
function subscribeLines() {
subscribeTimeout=false;
var vT=Session.get("visible_tiles");
console.log("SUBSCRIBE");
Meteor.subscribe("board_lines", Session.get("board_key"),vT.left,vT.right,vT.top,vT.bottom, function() {
console.log("subscribe board_lines "+Session.get("board_key"));
});
}
I've been a SysAdmin for 15 years. Without running the code, it sounds like an imposed limitation of the meteor.com server. They probably put in delays on the resources so everyone gets a fair share. I'd publish to another server like heroku for an easy deploy or manually to another server like linode or my favorite Joyent. Alternatively you could try and contact meteor.com directly and ask them if/how they limit resource usage.
Since the code runs fast/instantly locally, you should see sub-second response times from a good server over a good network.

Javascript GeoLocation Caching

I'm using the following to successfully capture user's location (mobile browser):
<script>
if ( navigator.geolocation ) {
navigator.geolocation.getCurrentPosition(handlePosition);
}
function handlePosition(pos) {
//this passes lat/long to additional code
}
</script>
This works, but often times the browser will seemingly cache the location data. The page that calls this geolocation code shows information relative to the user's location, so what happens is the user can move (change location), the page is reloaded, but the previous location data is used (showing incorrect data). Sometimes the page will have to be refreshed once or even twice for the page to use new location data.
Does anyone know of any means to force the code to get and use "up to date" location data each time script is executed?
FWIW, I'm experiencing problem in iOS Safari (6.1). Have not been able to test in Android yet.
Thanks for reading and for any help.
Edit: As Oleksiy has written in his answer, the Geolocation API now supports this. You can add {maximumAge: 0} as the third option parameter of getCurrentPosition. There is also a timeout and a high accuracy option available in the PositionOptions as noted in the specification.
Your navigator call would change to the following:
navigator.geolocation.getCurrentPosition(
handlePosition,
(error)=>{},
{maximumAge:0}
);
No can't be done. You don't have any control over the browser geolocation other than the code in your example. The html5 geo location api is very, very limited and that is a pain. I also had a question whether I could ask it if permission for the domain had already been granted and the answer was also no.
The problem is that the api is implemented in the browser itself and that are just no endpoints for these kind of functions.
What you could do is make an array in js to store previous locations and before you update your view test against that array to see if you got a stale location.
You do have this ability now.
getCurrentPosition takes three parameters: success, failure and options
Try this:
<script>
if ( navigator.geolocation ) {
navigator.geolocation.getCurrentPosition(handlePosition, (error)=>{}, {maximumAge:0});
}
function handlePosition(pos) {
//this passes lat/long to additional code
}
</script>

Categories

Resources