Does the viewports in the Google geocoding represents the boundary boxes of the location ? Iam trying to use google viewports of particular city or location to search for the latitude and longitude values that fall in those bounding values.
I have two tables called tblproperty and tblemailalerts, tblproperty has got latitude and longitude values and tblemailalerts also got viewport + latitude and longitude values . Now I want to get the sql to get the matching records with accuracy
I want to achieve similar to zoopla search
for example when user selects location as london , properties should be shown within the boundaries of london. If they select london within 1/4 mile radius i should get the properties within the london + properties with 1/4 radius
The viewport bounds parameter only biases the results. It's not a hard limit. You can read about viewport biasing in the API documentation.
However, the viewport returned by Google for a query for "London" does represent a bounding box you can use in your SQL query.
You could also use the OpenStreetMap API. The query to get a bounding box for London is:
http://nominatim.openstreetmap.org/search?q=London&format=json
In there you will find a number of bounding boxes for places called "London" around the world, but the first one is London, United Kingdom.
Related
In my google maps autocomplete server side query, i'm trying to return results around or near a latitude and longitude, I've tried this so far
https://maps.googleapis.com/maps/api/place/autocomplete/json?key=<<KEY>>&types=geocode&sensor=true&language=en&location=40.64131109999999%2C-73.77813909999998&strictBounds=true&radius=10&input=london
WHERE 40.64131109999999%2C-73.77813909999998 is the latitude and longitude of JFK - John F. Kennedy International Airport.
But when the search string is london, results still show. Any idea how to limit results within a certain radius / boundary or country? Thanks
Here are my findings on your URL request:
You have included strictBounds=true which is incorrect since parameters are case sensitive hence it will be omitted in the request. It should be strictbounds instead.
You also do not need the =true because adding the parameter strictbounds is enough to restrict the places returned within the defined location and radius.
The value of radius that you have included is too small (10) which may lead to ZERO_RESULTS
You may try this request instead:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=london&location=40.64131109999999,-73.77813909999998&radius=10000&components=country:US&strictbounds&key=YOUR_API_KEY
I'm trying to find all Panera restaurants within a 200 mile radius of a certain point.
Here is the URL I have been using so far :
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=39.52963,-119.81380&radius=321869&type=restaurant&name=panera&key=your-key-here
However, I have found out that radius has a maximum of 30 miles. Can anyone suggest a quick workaround for me?
Thanks to all in advance.
Open Google Maps and save 8-10 or more points' lat,long value to trigger your request. Then use a loop to find all places within these points. If you want more precise results, increase first trigger points for your requests.
I tried, it works.
Assume we are using php
$triggerPoints = array("lat1,long1", "lat2,long2", "lat3,long3",....);
foreeach(triggerPoints as $t){
$requestUrl = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=$t&radius=[YOUR_RADIUS_VALUE]&type=restaurant&name=panera&key=your-key-here";
$results = file_get_contents($requestUrl);
//Do what you want with response JSON data
}
Important: When you choose trigger points, those points should intersect according to your radius value. So you don't miss any restaurants
Business license with for higher usage limits.
Contact Google sales
Google place nearby search maximum 50,000 meters (31 miles) .
if you try enter more than 50,000 it not work proper.
There is another way for find all restaurants in a city.
google provide Text Search Requests
https://maps.googleapis.com/maps/api/place/textsearch/json?query=restaurants+in+Reno,NV,89501,USA&key={API_KEY}
query = keyword + in + city Name
for get city name using latitude longitude
http://maps.googleapis.com/maps/api/geocode/json?latlng=39.52963,-119.81380&sensor=true
For more information how to get city name using latitude longitude
https://developers.google.com/maps/documentation/geocoding/start?csw=1#ReverseGeocoding
for more information about how to use Text Search Requests
https://developers.google.com/places/web-service/search
I can get to know the suburb using google maps api. I use Autocomplete getPlace() to get sublocality_level_1. I want to know the nearby sublocalities as well.
I tried nearbysearch with type="sublocality". That fetches only maximum two results per call. Fetch with radius 200m returns two sublocalities and fetch with radius 500m returns two other sublocalities.
I want to get all sublocalities around given place_id for given radius (say 5000m). Is there a way to get that?
Looks like Google Places API doesn't have support for getting the nearby suburbs. You can only get point of interests like Restaurants, Fuel Stations, etc.
You can you the getPlace() Google Places API autocomplete to get the latitude and longitude of your suburb, and use the geonames.org API for fetching the nearby suburbs/sub localities. You have the options to pass lat, lng and radius.
Here is a example GET for fetching suburbs near 13.041703, 80.251943 in 5 KM radius
http://api.geonames.org/findNearbyPlaceNameJSON?lat=13.041703&lng=80.251943&radius=5&username=demo
I have a MySQL database that looks as such:
Postcode int(4),
City varchar,
State varchar,
Latitude decimal(7,4),
Longitude decimal(7,4)
I want the user to enter their post code (1660 for example) and a radius of x (lets say 10) miles or kilometers. When they hit search, I want to return a list of all the cities within that radius. I have a database that contains all of the post codes, cities, latitudes, longitudes etc. of all areas within Australia.
If you could sacrifice some precisions (by selecting cities within a rectangle area 10 miles from post code 1660), then the solution can be as simple as:
Find out the latitude and longitude of post code 1660
Calculate the top left and bottom right of the rectangle area (10 miles to the left and top, 10 miles to the bottom and right)
Use the query like: select city from table where latitude between bottom_right_latitude and top_left_latitude and longitude between top_left_longitude and bottom_right_longitude
If it has to be precisely radius 10 miles (which means the area is a circle), then the solution will be very complicated, couldn't do it in a single query I afraid. You need to think about some helper columns and use the distance and bearing calculations formulas to do it.
Reference: Calculate distance, bearing and more between Latitude/Longitude points
What should be the sspn value for 1mile X 1mile square on map for google local search api?
I tried out sspn value to be 0.01,0.01 but not very sure about this.
I need to search from google local search for businesses within 1 mile radius of the current user's position.
The latitude part of the sspn is 0.0145.
The longitude part varies depending on where you are. The closer to the pole you are, the fewer miles there are per degree. If you're on the equator, then it's 0.0145, the same as the latitude, but as you move towards the poles it gets larger in proportion to 1/(cos(latitude))
The equation is 180/(3959*cos(latitude)*pi) per mile.
However, since you only need the sspn values accurate to within a factor of 2, the values 0.015,0.025 would be sufficiently accurate for much of the Earth.