Check if coordinates lie in a region - google-maps

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

Related

Find city radius

I am working on an app where I need to check if some points are within a city or X km outside of it, so I need to find the city's radius then add the X variable to it. I've been looking on Google Maps and OpenStreetMap and I could not find such info.
Is there any API that provides the city's average width? Or distance between the center and the edge?
Based on the Latitude & Longitude of two given points, you can find the distance between those points.
So fetch the Location (Latitude & Longitude) for the centre of city and the point needed, using Google Maps API's and find out the distance implementing the logic.
Logic is described in below link :
http://www.movable-type.co.uk/scripts/latlong.html
Post calculation of distance, you verify if it is in the required range based on X.
I came across the same problem and here is the best method I found so far,
Using the service Geoapify
you can find the placeid for a city using the geocoding API
We can then create a location filter based on the place id as documented here
we can also use that filter for autocomplete to allow only for places inside the city

Google Maps Geocoder: Reference Position for Plain Location Names

I'm using the google maps api for geocoding addresses. If I geocode a plain location name (e.g. Munich) the api returns corresponding latitude and longitude.
To which position do these coordinates refer to? Is it the (geographical) center of the location or the position of the administrative headquarter or what else?
They refer to the equator which is latitude=0° and the prime meridian which is longitude=0°. This represents the central point (starting point).
You can look at it as to the Cartesian coordinate system starting from (0,0)=(x,y) and retrieving all the other places by changing the x(long) and y(lat) coordinates. So yes, the answer is geographical centre.
EDIT:
url (video): https://www.youtube.com/watch?v=Spel7vfkpNc starting at 2:43
Basically, companies within the country decide on which lat, long will a city, country when searched appear. For example if you are searching for London the pin point will be assigned to particular coordinates depending on the company decision.

Google Maps API v3 getPanoramaByLocation (StreetView)

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.

All Directions with google directions API

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

Google Map Distance Calculation

Does anyone know if Google Maps consider elevations and the actual path on earth to calculate distance between two points or it only considers geographical locations for distance measurement?
If you are referring to using google.maps.DistanceMatrixRequest then yes, it considers the actual route when calculating distance, based on the option provided in travelMode
code.google.com reference
When there is no established route (at least known to google) i'm sure (from experience) the response is the distance 'as the crow flies' between 2 lat/long locations. [experience based off making the request for a path that bisected a large lake]