I'm working on a project that picks random locations world-wide and need some functionality from Google Street View. I'm working with API v3 of Google Maps. The question I have is with the getPanoramaByLocation method. According to the Google docs, getPanoramaByLocation is :
"Retrieves the StreetViewPanoramaData for a panorama within a given radius of the given LatLng. The StreetViewPanoramaData is passed to the provided callback. If the radius is less than 50 meters, the nearest panorama will be returned."
The part I'm interested in is where it says "less than 50 meters, returns nearest panorama." So, for example, if I put in coordinates for somewhere in the middle of the Congo (where there isn't a street view for miles and miles), it should return a panorama of the nearest available street view. But it's not, it's returning null every time.
Is there a limit to how far away it looks?
Here's my Fiddle :
http://jsfiddle.net/nrJBP/1/
Thanks all, and hopefully this helps anyone in the future.
The service searches within the radius you give, as the docs state. You specify the maximum radius.
The service could find any Panorama data within the radius, except if you specify 50m, when it will always find the nearest (within that 50m).
You can use the google.maps.StreetViewStatus. If the request was successful, it will return OK. If there are no nearby panoramas, it will return ZERO_RESULTS.
Related
I used Nearby Search of Google Places API and sent a request with the radius parameter having a value of 1000 meters. My assumption is that the distance between any of search result and the target location will be less than 1km. But the API response gave me results that is beyond the 1km radius (like 1.3km).
I want to know if is this normal?
The Nearby Search radius parameter does not restrict the results to be within the circle.
Here's what the docs says:
"You may bias results to a specified circle by passing a location and a radius parameter. Doing so instructs the Places service to prefer showing results within that circle; results outside of the defined area may still be displayed."
Thus, the Nearby Search is working as intended if it gives you results a little bit beyond your search biasing using the radius parameter.
If I have a (latitude,longitude) pair, is there a way to determine whether it lies in a 'region'. By region I mean the 'highlighted' result of an query in google maps. For example, when I search for Manhattan, a red region is highlighted. Does Google/Bing provide an API to query if a given coordinate lie in such a region?
I am aware of the containsLocation API call that tells me if a coordinate lies in a polynomial already defined as a set of coordinates. The problem here is me not having all the coordinates that can define Delhi
Bing Maps provides an API called the GeoData API where you can pass in a coordinate and it will return the boundary information for the intersecting location (city in this case). https://msdn.microsoft.com/en-us/library/dn306801.aspx
Another method as mentioned by others in the comments is to use a reverse geocoding service. By passing in your coordinates it will return the name of the city in which that coordinate is in. Bing Maps also has a Reverse Geocoding service:
https://msdn.microsoft.com/en-us/library/ff701710.aspx
Really quick/simple question that will determine which map API i use for my project.
I dont need an example- ill figure that out, i just need to know if the capabilities are there.
If i have store geocode (latitude, longitude) coordinates in a database, can i put one of those little red markers on a google map without having to actually make a geocoding request from google?
Additional question:
Also, would it count towards any quotas every time i display one of their maps, even if i give them the geocoded coordinates? Because i mean technically their map still has to find those coordinates...
Q1: Yes — you tell the API the coordinates of where to put the marker, rather than get Google to find those coordinates.
Q2: The usage limits are published by Google. You can have up to 25000 map loads per day. If you don't use the geocoder because you provide the coordinates yourself, then you don't use a geocoder access.
I've got a problem with Google Autocomplete rest api.
I need to return predictions only for certain radius, but "radius" parameter doesn't filter incorrect results. Currently I get results from another cities and even other countries.
How can i force google autocomplete to not include any results that out of requested radius?
The location and radius parameters only act as a bias to the results, there is currently no way to restrict results to a specific radius. You can however restrict results to a specific country by passing the components parameter as detailed in the documentation.
If you use the location, radius and component parameters you will most likely get the desired results.
An example search for Eiffel Tower, with a lat,lng location in Melbourne, Australia, radius 50km, and country restrict to Australia returns "Eiffel Tower Chocolate & Confectionery" as the real Eiffel tower is not within the radius or in the country that the request is restricted to:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Eiffel+Tower&location=-37.816836,144.963123&radius=50000&components=country:au&sensor=false&key=your_api_key
You can use optional parameter radius.
radius — The distance (in meters) within which to return Place
results. Note that setting a radius biases results to the indicated
area, but may not fully restrict results to the specified area. See
Location Biasing.
The only way I can see to force this is to do the filtering yourself in the result array that you get when performing the search. I haven't used the Autocomplete API, but it seems you are using the Maps API to search? In that case, you get a GeocoderResult object which you can inspect the coordinates for the items, and compare them to your desired point and radius.
A bit hacky, but quite straightforward.
This example (uses the Google Maps API v3 places library):
http://www.geocodezip.com/v3_GoogleEx_place-search.html
from this answer:
Google places autocomplete - location and radius not working
uses rankby=distance
You can process the results to remove any not within your desired radius.
Is there a way I can get all routes from my current location to "any other location"?
By any other location I mean that the map should show all valid directions to locations I haven't specified. The range (in terms of distance) of the directions may be, say, 1 mile from my current location.
The only parameter I want to provide is my current location and check which all directions I can travel over.
No Google Maps can't do this nativity.
Might commonly be known as "Time Travel" Maps
Can see a crude demo
http://maps.forum.nu/gm_driving_radius.html