I want to implement autocomplete feature for google places.
I have created a project on google with places api service enabled.I am using iOS key for getting json data but getting following JSON response
{
"predictions" : [],
"status" : "REQUEST_DENIED"
}
I am also trying same request in safari with browser key, but still I am getting same response.
Please help.
Though this question has been answered by the creator itself, but I would like to tell few more points in detail as many people face this issue.
If you are using Google Pods / SDK then create iOS Key / Android Key whichever you want depending on your implementation.
If you are planning to use places API for autocomplete,
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Amoeba&types=establishment&location=21.76999,-122.44696&radius=500&key=[YOUR_API_KEY]
then the API Keys for iOS / Android will not work, for this case you would need to create a Browser Key from google console.
NOTE: If you want to use places API in your project don't forget to enable
from
Google Developer Console as shown below:
After this run your project / API you will get JSON response.
solved it..every parameter was OK but I sent sensor=false in the URL when I was using laptop.
Related
I've built a Flutter app using https://pub.dev/packages/google_maps_flutter for maps and I want to add directions as per https://medium.com/#shubham.narkhede8/flutter-google-map-with-direction-6a26ad875083, but I need to get the Google API key, which is injected into the app at build time in different ways depending whether it's Android or IoS.
I've spent about an hour googling, but I can't find a Flutter or native way of getting at the API key in the app. Is there a way?
If I understand rightly that you're trying to access the Google Maps API key from your native iOS and Android projects from within Flutter, this should work:
Use this: https://pub.dev/packages/flutter_native_config to read the Android manifest and the iOS Info.plist.
On Android the key will already be there as per the Google Maps docs.
You'll then need to move your API key in iOS to the info.plist then read it in instead of having it hardcoded: https://www.hackingwithswift.com/example-code/system/how-to-read-your-apps-version-from-your-infoplist-file
I have rendered google map in xamarin form iso but it is not working in android. I don't know if I am doing something wrong in my android setup or not.
My question is: can we use single google map api key in both application?
In google console I see:
Application restrictions specify which web sites, IP addresses, or apps
can use this key. You can set one restriction type per key.
Where i can choose only one option among http, ip, android and ios.
If tutorial link for google map in xamarinform would also be appreciated. I am using googlemaps nuget package.
According to Google, you should be using a different API key for Android and iOS for a better understanding I would suggest you read this document.
In your case, I would recommend you create an API key for your iOS app and another client API key for your Android app (different than the iOS one).
On your Developer console select create a new API key, you can see that Google gives you different choices: server key, browser key, iOS key, Android key, etc. Each different key serves different purposes and should be limited to the corresponding platform only (e.g.: do not put a server key in a client app like an iOS app, and vice versa).
As of an example, you can check this out.
The answer is Yes. You can use the same Google map api key in both application (Android/iOS), just use Xamarin.Forms.GoogleMaps NuGet
You can found a tutorial for GoogleMaps in Xamarin Forms in this answer.
These 2 sites have some sample code on them. I copied and pasted the code into a php page in localhost, and they worked fine. However, the code doesn't seem to contain any API Keys. How come Google allows the code to use the Maps API without Keys? I'm obviously missing something here. What is it? Are there use cases where API Keys are not necessary? Where can I see the documentation regarding such uses cases?
http://www.codeofaninja.com/2014/06/google-maps-geocoding-example-php.html
https://gist.github.com/lazarofl/3901081#file-geocoder_example-html
The Google Maps JavaScript API v3 does not require an API key to function correctly. However, we strongly encourage you to load the Maps API using an APIs Console key which allows you to monitor your application's Maps API usage
From: https://developers.google.com/maps/signup
It seems that the generated keys in the Google API's console are not working anymore. With different keys (tried it with both server and browser key, however the server key is what I need), generated from different accounts I get constantly the following errors:
Error when using server key:
{
"error_message" : "This site or IP is not authorized to use this API key.",
"results" : [],
"status" : "REQUEST_DENIED"
}
Error when using browser key:
{
"error_message" : "The provided API key is expired.",
"results" : [],
"status" : "REQUEST_DENIED"
}
And these are the enabled services on this account/project: http://upload.uprise.nl/et2j
This is the URL I'm trying: https://maps.googleapis.com/maps/api/geocode/json?address=900+Maple+Avenue%2C+L7S+2J8+Burlington+%28Ontario%29%2C+Canada&oe=utf8&sensor=false&key=mykey
Without the key it is working until I reach my daily limit (which causes the OVER_QUERY_LIMIT status).
Are more people experiencing this?
I have faced same issue... But finally got resolved. Google place services will take 10 minutes to make the services available for new API KEY created. Services will stat working after 10 minutes, till then we get error as "The provided API key is expired."
Geocoding is not one of the services available through the developer console at this time, which is why the key does not work (note that geolocation is not the same as geocoding).
Currently you'd need to use client side geocoding (for example in the JS Maps API) -- or purchase more server side geocoding with a maps for business license in order to increase this quota.
The fact it says the key is expired is misleading, and I'll file a bug for that.
EDIT/UPDATE: The geocoding service is now available through the developer console.
Enable
Google Places API Web Service from google console. It's work for me.
If you're switching from the free API services to a Maps API for Business implementation, you must remove the key parameter from your requests. Google Maps API web services will deny requests made with both a client ID and a key.
https://developers.google.com/maps/documentation/business/webservices/
For me Services has started working after 7 minutes.
I am new to google map api. I copied the Hello_World.html from google maps javascript v3 getting started. But I always get the error message: the provided key is not a valid google api key.
I tried a few things but none of them worked. The following is what I did:
I edited the allowed referrers to mysite.com/* and localhost/*. But the error message is still there.
I tried a method someone suggested, which adds javascript version number:
change src="https://maps.googleapis.com/maps/api/js?key={XXX....X}&sensor=true" to src="https://maps.googleapis.com/maps/api/js?v=3.6key={XXX....X}&sensor=true", even so, the error message is still there.
Can someone give me any suggestions?
You do not need a key for Google Maps API v3, see the documentation. Your API v2 key will not work.
You will only need key for API v3 in case you want some additional features (very high traffic site, additional statistics etc.). But this is a very rare case.
You don't need a key, it should work without it. If you provided the key you are using (it isn't secret and can't be used on domains that you don't allow), we could tell if it is at least the correct format.
This
src="https://maps.googleapis.com/maps/api/js?v=3.6key={XXX....X}&sensor=true
is incorrect.
it is missing an & between the v=3.6 and "key".
version 3.6 is no longer available, that will result in the "frozen version", currently version 3.11.
I had this problem. The solution is:
Go to https://code.google.com/apis/console -> api access
Click "Key for browser apps".
The example says to enter *.example.com/* but it doesn't work for me. I had to enter (one per line):
example.com
*.example.com
*.example.com/*
example.com/*
Hope this helps