I'm trying to get a list of all the Hungarian city names from google maps, but I don't know how. Is this at all possible?
As far as I know, there is no such possibility. Although Google Maps API lets you determine the name of the location by its coordinates (the Reverse Geocoder API) and lets you find coordinates of places that match the given name query (the Geocoder API), I'm pretty sure that it won't let you get all objects that match a certain criteria.
So the short answer is: no, it's impossible.
Related
I have a MySQL table containing a list of properties in the UK. The table contains the full address of each property including the post code. I need to be able to query the database to show all properties within a certain radius (e.g. 3 miles) of a given post code.
I've searched SO and couldn't find a similar question.
Research on Google seems to suggest I need to use Google Maps but I can't find any material to get me going. I don't need to display the results on a map at this stage, a simple list of the properties will suffice.
I'm not asking for someone to code this for me (although that would be nice!), I'm just after a point in the right direction.
Thanks.
If your properties are already accounted on the Google Server the Google Places API would be able to retrieve them. You just need to set the radius of 3 miles as parameter.
https://maps.googleapis.com/maps/api/place/nearbysearch/output?parameters
More details related to the parameter passed can be found in this official documentation.
If these places are not accounted in Google than they wont be displayed after requesting this REST API. Then you have to follow the standard procedure of:
Creating a query of fetching the requesting the address in within 3 miles with given postal address.
Select address from table where radius=3 & postalCode=xxxxx;
When you have the address convert them into Lat/Lng using Geocoder API.
Finally display them on Google Maps.
Hope this helps!!
i have a JSON file that contains lon and lat coordinates.
I want to parse this file and then create a new JSON file that contains only coordinates of a certain country.
Is it possible to do this? How to figure out what country the coordinates belong to?
In broad strokes, it sounds like you want to do what's called reverse geocoding. This is the process of taking a known set of coordinates and getting an address from it. The address would include the country.
Depending on the size of your data set, Google offers one that might suit you. You could write a routine to iterate your data set, reverse geocode each set of coordinates, and get a structured address (including country), which you could cache for future use. With the countries, you could then filter the list down to the specific country you're looking for.
I'm essentially trying to build a kind of store locator using Google Maps geocoder, but I want to find a way to write code that returns the nearest stores as hyperlinks on the page (probably inside a div), without placing everything on a map. I don't want to use a map, or markers and infowindows, etc... at least not to begin with.
I've followed a lot of the Google Maps API tutorials online, and it's been easy enough to build a basic working store locator that returns a set number of results inside a given radius by checking the input latlng against the values in my database, but I'm not all that skilled at js, and was wondering if anyone knew of any tutorials that might demonstrate the use of the geocoder for returning latlng search results just in text format, without a map.
Thanks.
The use of the Google geocoder is not allowed without using the results on a Google Map.
Note: the Geocoding API may only be used in conjunction with a Google
map; geocoding results without displaying them on a map is prohibited.
For complete details on allowed usage, consult the Maps API Terms of
Service License Restrictions.
For the site I am building I want the user to be able to search for a location, however because I don't have a list of locations for the UK, I have developed a script in PHP which calls: http://ajax.googleapis.com/ajax/services/search/local in order to get the lat and lon coordinates of this location to store in the database for future use.
This works well apart from if I search for a town, for example Heaton, it brings back the one in Staffordshire rather than the one in Newcastle for example.
The whole reason I'm using the google ajax api is to cut down the google requests per day because I don't want to exceed the daily request limit.
As you can see though, I've hit a brick wall because the search isn't refined enough to bring back the correct location.
Can anyone suggest another way around this? I'm quite stuck. Thanks
I don't know if you have seen this already, but there is a parameter in the Google Search API that allows you to specify a boundary for the search:
GeocoderRequest object specification
The specification for a geocoding
request to be sent to the Geocoder.
Properties Type Description
address string Address. Optional.
bounds LatLngBounds LatLngBounds within which to search. Optional.
language string Preferred language for results. Optional.
location LatLng LatLng about which to search. Optional.
region string Country code top-level domain within which to search.
In your case I would specify a bounds around northumberland, so something like:
http://ajax.googleapis.com/ajax/services/search/local?q=heaton&v=3.1®ion=GB&sensor=false&bounds=(55.395,%20-2.510%20,2054.342,%20-0.417)
might work...? I don't know if this would be relevant to your app though. Good luck!
Google maps has a function that lets you retreive the distance between two points: getDistance(), of the GDirections class.
Now, this is Javascript, so it'll only be able to calculate once the page has loaded.
My search form however, has the ability to indicate what's the maximum distance you want between yourself and another person and based on that, a list of search results has to be provided.
Since I can't use this function in PHP, is there another way for me to calculate the distance between 2 points on the earth? By giving up the street, postal code and city name, just like what Google maps needs.
This page has a list of google maps parameters for use in http connection. By specifying the output paramter you can choose to give back kml files or similar and can be used in any lanuage that can make http connections.
Looks like you want to calculate a Great Circle Distance
Formulas have been discussed here on stackoverflow before.
A point on earth is defined by it's latitude and longitude. If you want to calculate the distance between 2 points on earth by giving up the street, postal code and city name, you will need geo-referene data.
This data is available for free on the internet, but the accuracy and availability differ greatly from region to region. (USA data is of good quality, data for Kenia for example will be harder to come by)
So to answer your question:
Yes, there are other ways to calculate what you want. But they require more work/are more complex than just querying the google API.
You might want tot read: Creating a Store Locator with PHP, MySQL & Google Maps
Hope this points you into the right direction.
You can use kml file. It's xml-formatted file that you can recieve by link like http://maps.google.com/maps?f=d&hl=en&saddr=<src latitude>,<src longitude>&daddr=<dist latitude>,<dist longitude>&ie=UTF8&0&om=0&output=kml
in recieved file you can parse and summate distances from