I have read this post and it looks very promising. However, the answer does not go in detail with regards the implementation.
Basically, given the latitude and longitude, how can I use the GeoNames Web Service to get the country. I would like the returned result to be stored in a variable so that I can then continue working with it as I wish.
Thanks in advance
Do you have to use javascript for that? Geonames doesn't seem to offer a javascript api for doing your exact query (see here: http://www.geonames.org/export/JSON-webservices.html). And remote file fetching via javascript is not a joy.
If you could use php for that, it would be as easy as
$country = file_get_contents("http://ws.geonames.org/countryCode?lat=49.03&lng=10.2");
Related
We are using Yahoo YQL geo code finder to find a country code using the latitude and longitude.
Following is the url used,
http://query.yahooapis.com/v1/public/yql?q=select+*+from+geo.placefinder+where+text+%3D+%2751.5073509%2C+-0.12775829999998223%27+and+gflags%3D%27R%27+&format=json
It used to work earlier, but suddenly it has stopped providing the country code.
Following is the result given,
{"query":{"count":0,"created":"2016-02-11T06:35:28Z","lang":"en-US","results":null}}
Please help me to find a solution for this.
Regards,
Neha
Checking the yahoo console. I can't find any reference for the table geo.placefinder
Are you sure that you are using the correct API and the correct parameter.
I have run a geo location query
select * from geo.places where text= "SFO"
http://query.yahooapis.com/v1/public/yql?q=select+*+from+geo.places+where+text+=+%27SFO
Which gives me the following result
{"query":{"count":1,"created":"2016-02-11T08:09:34Z","lang":"en-US","results":{"place":{"lang":"en-US","xmlns":"http://where.yahooapis.com/v1/schema.rng","yahoo":"http://www.yahooapis.com/v1/base.rng","uri":"http://where.yahooapis.com/v1/place/12521721","woeid":"12521721","placeTypeName":{"code":"14","content":"Airport"},"name":"San
Francisco International
Airport","country":{"code":"US","type":"Country","woeid":"23424977","content":"United
States"},"admin1":{"code":"US-CA","type":"State","woeid":"2347563","content":"California"},"admin2":{"code":"","type":"County","woeid":"12587707","content":"San
Francisco"},"admin3":null,"locality1":{"type":"Town","woeid":"2487956","content":"San
Francisco"},"locality2":null,"postal":{"type":"Zip
Code","woeid":"12797178","content":"94128"},"centroid":{"latitude":"37.62207","longitude":"-122.383659"},"boundingBox":{"southWest":{"latitude":"37.603939","longitude":"-122.403732"},"northEast":{"latitude":"37.64463","longitude":"-122.35482"}},"areaRank":"1","popRank":"1","timezone":{"type":"Time
Zone","woeid":"56043663","content":"America/Los_Angeles"}}}}}
Sorry for the hard format, I can't get the tags to work the way I want it.
https://developer.yahoo.com/yql/console/#h=SELECT+*+FROM+geo.places+WHERE+text%3D%2251.5073509%22
I have found a solution which works fine in my case.
The yahoo API service is unavailable for query format, hence I have used the below format.
http://gws2.maps.yahoo.com/findlocation?q=51.5073509%2C%20-0.12775829999998223&gflags=R&format=json
Regards,
Neha
i'm using this api below to find out nearest hospitals.In response json i'm not getting the contact number of those hospitals. how do i get that????
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=22.5531,88.3564&radius=500&types=hospital&sensor=false&key=AIzaSyBdBBjxmc51SAqsefefwgwtSyjxT6NPMUAtYA
You can get only thos info which is provided by the api. Please go through this link it has a nice explanation about the apis https://developers.google.com/places/documentation/search
I think, some of these APIs are closed, so i don't see a solution with Google APIs. Maybe geonames.org or OpenStreetMap gives you a better chance for the data you are looking for.
Overpass Turbo
I have searched extensively for this answer. Maybe it's just too simple to be posted. Please forgive me I am missing something really obvious. I am trying to use a piece of data (number value) from a GET request (I think it is the r_object value) that I access via a URL with an API key.
I am using an external service (called "teleduino") to read data (moisture/voltage readings) from a microprocessor unit (Arduino Uno with Ethernet shield). I use my personal API key from teleduino and the teleduino service uses php GET requests (in a JSON format I think). I can load the results into an iframe on my web page using javascript, but I need to use a real variable of the data not just view it in an iframe.
For example, if I load "http://us01.proxy.teleduino.org/api/1.0/328.php?k={my-key-here}&r=getAnalogInput&pin=16" into an iframe I get something like this (when the device is online) :
{status":200,"message":"OK","response":{"result:1,"time":0.22702789306641,"values":[877]}}
The number in the square brackets is the value I need to extract as a simple variable so I can display it on the page (instead of using iframes) and also use it in mathematical calculations and other functions.
That value I need (in the square brackets after "values") is I think the "r _object" in the $GET request because when I observe the URL : r=getAnalogInput&pin=16 is the crucial data I need. (It is the number of a voltage given on pin16 of that microprocessor, which refers to the soil moisture of that plant).
I have searched extensively but cannot find out how to load that value from the get request into a variable so I can use it in the javascript on my page.
I assume it is some simple php like
moisture = $_GET[URL,"values"] ....etc etc
I am assuming it is the php r_object. And I assume I need to use php or ajax as the data is coming from an outside server (the teleduino service), so pure javascript will not work.
I am happy to write some php onto the php file of my webpage, but I do not know what that php should be.
ANY ideas would be greatly appreciated - thank you so much!!!
$_GET is for getting parameters that were passed as parameters to your PHP script, not results from a remote API. I think this is what you want:
$results = file_get_contents($url);
$data = json_decode($results, true);
$moisture = $data['response']['values'][0];
I'm looking for a way to get a user default language by the country. For example I have windows in english but still I would like to get my country 2 letter language ("cs")
You can see an example of what I want, In the source code of http://search.conduit.com/ using (Autocompleteplus) as well. This is what I see:
window.language = "en-us";
window.countryCode = "cz";
window.suggestBaseUrl = "http://api.autocompleteplus.com/?q=UCM_SEARCH_TERM&l=cs&c=cz&callback=acp_new";
You can see the api url has inside "l=cs&c=cz" how did they get this information? I would like to have the same thing I use the same autocompleteplus method just need a way to generate the l=(user true langague)&c=(country code) and performance is important as well. It's autosuggestions for my website search.
This is Ed from AutoComplete+. Getting the user country is typically done when using our API through server side implementations. There are however some open APIs that can assist you. Regardless, you can use our autocomplete feed without the user country. Feel free to contact us directly for further info at http://www.autocompleteplus.com
Thanks,
--ed
Is it possible to find geolocation using zip code using PHP.
For example, if i am entering the zip code i need to find the name of that particular zipcode.
Is that possible? if yes kindly explain me how?
Thanks in advance
See the duplicate question on how to turn an address into coordinates using the Google Geocoding service.
A query in the format [zipcode], United States, e.g..
72116, United States
should always work for you.
Try maps.google.com to simulate the request.
The XML returned from the Google Service will contain the official place name, as well as other information like county and state names etc.
You can do this through Javascript and PHP using Google's Map API - check this question for an example of how this is used.
I dont think it can be done solely through PHP however because you'd need to access an API's data and they normally (not always) do this through javascript.
You should check the API documentation.
You can access the Geocoding API solely using PHP.. you don't even need an API Key anymore.
http://code.google.com/apis/maps/articles/phpsqlgeocode.html
So if understand this correctly, you want to know the City/State of the zip code you have entered?
Maybe you should look into the Access database here :
http://databases.about.com/od/access/a/zipcodedatabase.htm
And if you find it useful, just convert it into a MySQL table and use as you please.