I am programmatically trying to get latitude and logitude for an address on a google map web page. Is there any way to do this?
Update:
I found out how to do this in the end. Send a request to:
http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true_or_false
I found out how to do this in the end. Send a request to:
http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true_or_false
Related
I am trying to use react-geocode to get a user's address from their lat/lng coordinates, but unfortunately I am getting the error API keys with referrer restrictions cannot be used with this API. Is it possible to get react-geocode to use a different API which does allow referrer restrictions? Otherwise how would I go about doing this, as I cannot remove the referrer restrictions for my API key. Is there a way to reverse geocode lat/lng coordinates using the Google Maps API which I am already using to display my map anyway?
import Geocode from "react-geocode";
Geocode.setApiKey("AIzaSyDsb7F-VyBJn7r4LilYH_lRHBpPfgyUga8");
Geocode.enableDebug();
Geocode.fromLatLng("48.8583701", "2.2922926").then(
response => {
const address = response.results[0].formatted_address;
console.log(address);
},
error => {
console.error(error);
}
);
CodeSandbox
If you want to switch to Google Maps, their (reverse) geocoding is pretty straight forward. Obviously you want to get a Google Maps API Key (get it here) to write a GET request:
https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=YOUR_API_KEY
Parsing the results should be easy. :)
Sources:
https://developers.google.com/maps/documentation/geocoding/intro#ReverseGeocoding
https://developers.google.com/maps/documentation/geocoding/intro#reverse-example
It means Google has blocked access from referrer-restricted API key, and it's very unlikely that Google has two versions of same API with different API restrictions, so you can't use Geocoding API with your restricted key. But you can create other API key with other restrictions applied, i.e. IP restriction.
Did you consider using reverse proxy function of web server? for nginx, you can set it the same to the restricted website configured in your google geo api with command proxy_set_header.
However you have to change the GOOGLE_API to your own webserver here in react-geocode .
Since you've placed a referrer restriction on your API key, it will be limited to executing on the browser with the web service APIs, including the Geocoding API. It didn't work for me even when manually setting the referrer in the request headers. You can find the other web service APIs on this page: https://developers.google.com/maps/web-services/
Important: If you are using any of the web service APIs with an API key that has referer restictions, your requests will fail with the error message: "API keys cannot have referer restrictions when used with this API." You should switch to using a server restriction.
You'll want to create a separate key to use server-side. You can change your restriction from a browser restriction to a server restriction by using IP addresses to restrict access, instead of browser referrers.
Alternatively, you can continue using a browser key and geocode client-side (JavaScript), then return the result to the backend.
You have to add Geocoding API
to your google maps library, and then you can add to your API restrictions for your API key.
I'm using the instagram API to get some images related to an specific hastag but when I call the API I get a message saying the API is deprecated.
I'm calling this endpoint
https://api.instagram.com/v1/tags/{tag-name}/media/recent?access_token=ACCESS-TOKEN
Any idea on what call I need to make to return the list of images with the requested hastag?
So I figure out why this is happening. Because the application is still in sandbox mode I can only get hashtag from the accounts that have access. Once the application is approved it will be able to pull the data from the API.
Hi I am working on a classified site using AngularJs SPA and Web Api. The requirement from my client is:
When the first request comes from the browser on our domain (www.mydomain.com), it should be redirected to the requested country subdomain like uae.mydomain.com (If request is coming from UAE), usa.mydomain.com (if request is coming from USA), china.mydomain.com (if request is coming from china).
I am searching over google for quite a long time now and I am surprised that not much help is available which can guide me to the right direction. Please show me the right direction.
Im using the bing maps REST services from server side code. I want to set the userIp parameter to 127.0.0.1.
Can you guys provide the steps how to set the value.
Thanks
Add &userIp=127.0.0.1 to your REST URL
I am using Google Apps API for my application with OAuth2. ,but I get an error.
Error: invalid_client
no support email
Request Details
That’s all we know.
If you create OAuth credentials BEFORE you set the support email address in the consent screen, then it appears that you will always get this error, even after setting the support email.
I resolved this by setting the support email, and then recreating all necessary OAuth ids in the credentials page.
In the Google Developer console make sure that you have added a product name and an email address under. Apps & auths -> consent screen.
Update: This shouldn't be to much of a problem anymore. Google made a change in the console that wont let you save anything until you have updated these items.
In Google Developer Console turn Gmail API on.
GDC > Dashboard > Use Google APIs > Google Apps APIs > Gmail API
Be sure that you are set up the setDeveloperKey with your EMAIL ADDRESS offred in Google Console whe you create a Client ID for web application.
Had the same problem and the solution was:
Set my email
Recreate the keys
Activate Google API+ from API Library
1) Fill out the info email address and produce name as well as other details in the 'consent' screen on google's console when you generate the keys.
2) And make sure when you copy paste the ClientID and ClientSecret code from google to your workspace (IDE), there might be some unwanted spaces inbetween
Check with the google console and remove it.
Hope this helps,
--happy coding!