Draw an area on google map and get a list of all cities covered by that area - google-maps

Is there any such functionality provided by google maps API, such that I draw a random area on google map and then through some functions in the API, receive a list of all cities and sectors that were covered under that drawn area ?
Any information or help is greatly appreciated.

No, that functionality does not exist (as far as I know, anyway). You can try to fake it by selecting a sufficient number of points in your polygon and reverse geocode them, but obviously that is an imperfect solution in terms of both performance and completeness.
Barring that, there may be resources that you can license for a fee or there may be a resource made available by the government of India that may help you solve this problem. (Or perhaps there is not. I'm speculating.)

Related

How does Google Maps represent an area as a point?

Google Maps does an excellent job of using polygons to represent areas wherever possible, particularly from the search bar:
But in some cases (navigation) a point geometry is required, no matter how vague or large-scale the area being searched, and this can result in some funny-at-best, completely-wrong-at-worst locations:
There are two ways that I know of that are widely used to generalize a polygon to a point:
Calculate the geometric centroid (there are various ways to do this but they'll all produce similar results)
Choose an point of administrative importance (i.e. navigating to "New York, NY" takes you to city hall)
In some cases Google appears to do neither of these things, and I can't figure out how the point was chosen. Specifically, navigating to "Vermont" directs you to a field on the outskirts of a village in the Northern part of the state, far from any examples of 1. or 2. above.
What other method could Google be using in cases like this?
I've received information from side channels that this is a quirk of Google's geographic features algorithm. Many thanks for the suggestions, but this one appears to be less of a mysterious puzzle and more of a transient bug.

Finding businesses with Google Virtual Tour panoramas

I am wondering if it's possible in any way to get a list of businesses that have done a Google Virtual Tour (basically a Street View, for businesses) by querying in Google Maps API.
I was hoping that perhaps the Places Library might contain this information in a response, but no dice. This is kind of visible in an everyday map (see Hotel Boulderado) but I don't think the information is included in any kind of query I can do.
I also saw a few questions dealing with finding a Street View by a specific LatLng - I'm looking for a more general, area-based search.
Any ideas or things I missed?
I was hoping that perhaps the Places Library might contain this information in a response
Places API can provide you a "list of businesses" in an area by trying to filter it up with specific Place Types. You are, however, limited to the constants the API provides. If you're using PlacesService, you can use nearbysearch which I think is more appropriate to your case.
I also saw a few questions dealing with finding a Street View by a specific LatLng - I'm looking for a more general, area-based search.
I'm not sure what you mean by "area-based search", but Street View on a specific LatLng can be tricky since its only available on some areas. The Explore StreetView site highlights what countries currently have data (zooming in suggests that it doesn't necessarily captured the whole country; mostly are road routes, etc.)
A StackOverflow entry indicates a way to handle if StreetView is available or not.
Hopefully the answer raised some clarifications in your end.

Getting all streets visible in Google map's viewport

I'm trying to build a map with the following algorithm:
Wait for pan or zoom to occurs.
Query for all streets visible in the viewport (extent).
Color every visible street with a predefined color.
Example:
I want to show the numbers of businesses on each street, or the number of crimes committed at each street.
I have a DB which holds this kind of information (streetname, data), but each row doesn't have the location data.
Therefore, after each map zoom or pan, I cannot query all of it by a geographical bounding rectangle, it will be far more efficient to use Google own DB and query it by street names.
I know how to register to pan and zoom events.
I know how to calculate the viewport coordinates.
I know how to color a single street.
How can I get a list of all streets visible in the viewport?
Any other solutions or architectures are welcome.
The preferred solution will not use Google DirectionsService nor DirectionsRenderer since they slow down the map.
My understanding is that what you are asking is not possible from Google API's. Reverse geocoding inside a polygon is not a service they offer. There are some posts on other sites (e.g. https://gis.stackexchange.com/questions/22816/how-to-reverse-geocode-without-google) with the reference gisgraphy.com looking like a pretty neat reverse geocoding tool.
This still does not address your all streets in a polygon problem however. I think your only option would be to get your hands on the data (Open Street Maps) and write the code yourself. Further - if you are going to do this for a large area I would take an approach like I recommended here with grids: https://stackoverflow.com/a/18420564/1803682
I would create my grid elements, and for each street calculate all the grids to which it belongs and store in the database. Then when you search a polygon, you would calculate all the grids the polygon overlaps, and can then test the subset of road data in each of those squares to determine overlap.
I looked into this and abandoned a similar requirement a few months back and still have a desire to implement it. Most of the point/line in polygon work is happening on data created in my application (i.e. not street data) and right now that is the only data I will be including. What I am trying to say is - I hope someone gives you a better answer.
Update:
For what you are asking I still believe you will need to use a mix of your own database based on OpenStreetMap and some kind of grid analysis carried out in advance. If you have some time to commit to the project this should not be too awful to process. The database will be large, and the calculations needed will likely require a significant amount of one-time / upfront processing time. As far as highlighting routes/roads/whatever within the viewport, there are lots of way to accomplish this using the API - example here which I found useful: polyline snap to road using google maps api v3
Also useful: http://econym.org.uk/gmap/snap.htm
Note that one way streets may give some grief if using the directions api to snap to a street and you will likely have to watch for this and correct or reverse the start/end points.
Google would recommend using it's Geocoding Service in order to populate your data base with the co-ordinates. You can then use the LatLng Bounds Class method "contains" to check whether your points lie within the viewport. The advantage of this approach is you only need to geocode the information once and then store this, versus sending coding requests each time the viewport changes.
An alternate efficient way of displaying this kind of data may be to use google fusion tables. this greatly simplifies the integration of the data with the map.

How to find the elevation of a lon/lat polygon

I am trying to create an application that uses terrain information about an area. I use lon/lat (4326) polygons from a kml file and store the geometries in postgis.
I need to find the elevation fluctuations of a particular area (polygon) defined by lon/lat points. How is this possible? I have read certain possible solutions like DEM but i do not how to use them.
Is there any other way of achieving it?
Thanks in advance for your replies.
Surprisingly there is a Google Elevation API :) (mainly for Android development, you need to register for a proper key):
https://developers.google.com/maps/documentation/elevation/
Maybe you could use the JavaScript API of the same service (I haven't tried this one, just found the link from the previous one):
https://developers.google.com/maps/documentation/javascript/services#Elevation
Probably you can us it, but beware of this:
Use of the Google Elevation API is subject to a limit of 2,500 requests per day.
The good thing is that in one request you can get elevation data about a Line, with arbitrary number of divider points (the dividers are sectioning the line into equal length sections).

How do I discern a country from X/Y Coordinates (or Long/Lat)?

I have a number of XY coordinates and am looking to discern which country each of these are in, who knows a good service/way of doing this?
I am working with MySQL & PHP, not that its really relevant, I am o fey with consuming web services/pages and assume there must be a web-service/page somewhere which will do this, if someone can point me in the right direction that would be awesome.
How do I take: 306458,383136 and turn it into: United Kingdom (for example.)
Appreciate your responses in advance.
What you're looking for is called reverse geocoding, and e.g. Google Maps has this functionality: http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding
It works from a Lat/Lon coordinate, and could return even a more precise information than only a country; note that this is only an estimate - in some places, country boundaries are somewhat tangled.
If you're looking to do this offline, or if Google's/Bing's/whoever's licensing is too strict for you (e.g. you need to do a gazillion of requests per day, or need to present the result in an unorthodox format), it's possible to run your own instance of Nominatim, feed it a data extract from OpenStreetMap (under ODbL, a much more permissive license), and query that.
For example, there's a set of boundaries available at https://wambachers-osm.website/boundaries/ - just the national boundaries, so you wouldn't need to download the entire planet map.