Google Places Autocomplete API Consumption - google-maps

I'm using google maps API on my company, and we're facing some issues with the consumption of the API.
We use the Javascript API, loading the map, and we geocode some address and make some routes. Everything normal.
But we use the Autocomplete in some cases, to allow the user to input the location he's searching.
So, I define the autocomplete like this:
var autocomplete = new google.maps.places.Autocomplete(
document.getElementById('textBox'),
{ types: [] });
When the user select an option, we call the function
autocomplete.addListener('place_changed', doSomething);
get the place and do more things
function doSomething() { var place =
autocomplete.getPlace();
//more code }
Everything works fine, but when the user start typing, it's been consuming the Google Places API Web Service. Is it right?
I thought it would only consume the Javascript API when we loads the map, and that's it.
And the weird thing is that, on the developer's console, the utilization of the API started few days ago (30/06/2016), and we have a gap of no utilization of this API (between 3th and 10th of July), and yesterday we reach the limit of 1000 uses.
Am I doing something wrong? What can I do?
Sorry if this is not the right place for the question, and if it's not, move it or tell me so I can open in the new place.
Thanks

You can find an answer in this blog post:
http://googlegeodevelopers.blogspot.com.es/2016/06/building-for-scale-updates-to-google.html
Look at 4. Starting from June 22, 2016 Google counts client-side requests against the corresponding web service APIs. Apparently, some of your domains were "grandfathered", but the new ones will follow the new policy.

Related

Google My Maps - API

Is there any way to add Layers, Points, Directions or any data to a map in the Google My Maps, using API?
I have searched in Google but didn't find a solution to do this.
Currently there is no any API to access MyMaps programmatically.
I can see a feature request for this in the public issue tracker:
https://issuetracker.google.com/issues/35820262
It looks like Google is evaluating the feasibility to implement the API, however, no timeline provided at the moment.
Please star this feature request to express your interest and receive further updates.
UPDATE
As of April 2018 it looks like Google decided do not implement the API for Google MyMaps and marked the aforementioned feature request as Infeasible.
This is not a fantastic solution — and it does not use the API — but it might fit your needs. Instead of using the API you could write a browser console script that adds each new item. You could probably even run this through a headless browser and remove any manual interaction altogether.
eg.
fetch('https://example.com/newLocations')
.then((response) => response.json())
.then((newLocations) => {
newLocations.forEach(location => {
document.querySelector("#mapsprosearch-field").value = location.name + ", " + location.city;
document.querySelector("#mapsprosearch-button > div").click();
document.querySelector("#addtomap-button").click();
// etc.
});
});
—
UPDATE
Re-opened as of Feb 2021 — API support for this has been assigned. So hopefully we get support soon!
https://issuetracker.google.com/issues/35820262

Google places maps Api web service post new place

I just posted 2 places with the Add Place API.
I used this model and got a success status confirmation by the webservice and then for each I got an id, and place_id, reference, scope and status
But the problem is I cannot see my new places on the google maps interface. where can I find my places to check if everything is right?
if you take a look at the documentation:
When you add a place, the new place is available immediately in Nearby Searches initiated by your application. The new place also enters a moderation queue to be considered for Google Maps. A newly-added place does not appear in Text Search or Radar Search results, or to other applications, until it has been approved by the moderation process.
Which means everyone can add their own places for the own use. But in order to have your place visible to other apps or the Google Maps, it needs to pass the moderation process. If your places did not show up after a week or so, then probably it didn't make it through.

Get latitude / longitude / Reverse Geocoding without displaying maps

Using a website, I am trying to capture user's latitude / longitude point and based on that grab his current address.
I am able to do this using Google Maps API: geolocation and Reverse GeoCoding. But, my requirement is to get this information without displaying the map. As far as I have read, Google Maps Term of Use prohibits such thing.
Can anyone let me know if there is any other service which can serve my purpose without displaying maps or does Google Maps allow such thing? I am not sure about Bing, Yahoo.
EDIT: On page load, I need to grab user's latitude and longitude and based on that get address information. I am planning to use this address information for displaying nearby locations/places to visit. I have to achieve this without displaying any map.
Yahoo PlaceFinder does it. If you pass through the latitude and longitude in the location parameter and gflags=R, it should return address data.
You'll have to get a Yahoo APP id, but its free and pretty easy to set up.
EDIT: I see you want to do geolocation too, if you can't use google I would investigate html5 geolocation and or use freegeoip.net to geolocate by ip address.
I don't know if Im mistaken this post, but if you read this:
(viii) store or allow end users to store map imagery, map data or geocoded location information from the Yahoo! Maps APIs for any future use;
(ix) use the stand-alone geocoder for any use other than displaying Yahoo! Maps or displaying points on Yahoo! Maps;
It's mean that you can't store the information, or make use of it, without maps.
So the google api and the yahoo api need to have a map...
note- I take that lines from the terms of yahoo: http://info.yahoo.com/legal/us/yahoo/maps/mapsapi/mapsapi-2141.html
EDIT - Now I'm trying to use http://www.geonames.org/export/reverse-geocoding.html It's easy, and works fine for me. I just need the city and maybe a postal code.
I don't think Yahoo requires you to show a map and it also has a higher quota.
http://developer.yahoo.com/geo/placefinder/
There are a number of geolocation APIs - here is a really good one:
https://geoip.nekudo.com/
You merely make a GET request to
http://geoip.nekudo.com/api/{ip}/{language}/{type}
where ip, language and type are optional.
E.g. in Angular 5, using HttpClient:
this.http.get('http://geoip.nekudo.com/api/')
.subscribe(
data => { console.log('SUCCESS! Your coords are lat:', data.location.latitude, 'long:', data.location.longitude); },
error => { console.log('ERROR!', error); }
);
Also, note that the geoip service is written in PHP and open source (https://github.com/nekudo/shiny_geoip) so you can house your own implementation to reduce third party dependencies.

Google Maps - Places library - Search for custom placed markers in radius

I'm developing a app that makes use of the Gmaps Places library and actually, I have two questions:
1) Does anyone know how long it takes to an added place(by POST request) to show up on the map? I only need it on the app's map, so I don't care if Google doesn't approve it. I've already sent the add request and received OK as response.
2) It is possible to search for markers, placed by me, as if they were places(and using radius)? Not necessarily using the Places library. I ask this to see if is possible to come with a backup plan if the waiting mentioned above is long(clients, clients...). Then I would have the places 'offline from Gmaps', mapped inside a JSON file.
If I understand you correctly, you want to combine Google's Places API with a custom location set? Without more detail I can't really tell you what the code would look like, but you'd basically want to mash up the results you get from places with your own data and place markers based on that merge. If you're searching by radius or polygon you can do a 'within bounds' search on your dataset and return any results that are within the search zone to feed into your marker creator.

google map V3 - private kml feed

I am trying to switch from virtual (VE) earth to google map (GM).
It is pretty easy to overlay a georss feed over a map in VE as well as in GM:
var georssLayer = new google.maps.KmlLayer('www.bla.com/kmls/k1');
georssLayer.setMap(map);
Unfortunately, google requires the 'kml address' to be public. What can I do to achieve the same functionality if my address is not public (e.g. when the user has to login before [s]he can enjoy the map)?
Thanks.
Christian
I've thought about this issue before and this is the solution I've come up with (although I haven't implemented it yet).
The server code that generates the html page in which the map is embedded should generate a temporary token that is tied to the current user in the database.
Make the KML address public, but pass the temporary token to it as a query parameter
Include logic in the KML server code that checks the passed token to be sure it is valid
The token should only be valid for a limited time.
This solution will be slightly less secure than full id/pw authentication on the KML resource. But by using a short lived token, it may be good enough, depending on your requirements.