Finding the location in google maps - google-maps

We have been using google maps api , but have a clarification. Is there any method which allows the user to know the nearest city as in when the user moves the mouse over the map .
Like the user hovers over the map from one country to another country, so is there any way to display the city name outside the map through an event.
I am aware that it is possible to get the user's current location through geolocation propertY, but is it possible to get the requirement described above ?

For what I know I can use reverse geocoding to obtain the designation of a place where you are based on its coordinates. At this point the problem is to define what you mean by the nearest town, you mean the center of the city where you are or drawn a town bordering the town where you are. In the first case using the name of the city you've got you can find with normal geocoding coordinates of the center of this city, in the latter case you have to develop a specific strategy.

Related

Google Place API city search by coordinates

I'm trying to access cities from the google place API. I want to be able to search with coordinates and have it return a city. My goal is for a user to be able to enter in a city and a photo shows up. So after getting the city, I will use the photo reference to get the image.
This is my request
https://maps.googleapis.com/maps/api/place/search/json?location=35.4107,80.8429&radius=100&sensor=true&key=API_KEY
the coordinates entered is a City in North Carolina. However, it does not return a city within North Carolina at all. All I am looking to do is use coordinates inside my request and have it return the city the coordinates are in. I'm relatively new to development, if I have been unclear in any way please point it out so that I may correct myself. Thanks!
I believe reverse geocoding is more suitable for your task than Places API. Places API is designed to search businesses and POIs at first place, localities shouldn't be among the results.
With reverse geocoding you can specify a coordinate and type of result you are looking for. For example, to search the city use the following request
https://maps.googleapis.com/maps/api/geocode/json?latlng=35.4107%2C-80.8429&result_type=locality&key=YOUR_API_KEY
This will return the "Huntersville, NC 28078, USA"

properties of a place viewed by Google Maps

I am building a site that helps people to find restaurants on the net .. so i want for every restaurant to show a small Google Map
Now i'm still building my database, in the table restaurant i have id ,name , phone, website, ....
My question is do i have to add other properities to help me locate the place exactly on Google Maps, what are they?
Please note that this is my first time to work with google maps, and i really dont know what do i need exactly to know about a place to represent it on the map.
Thanks
There are several ways to locate a place. First, you can do it through latitude and longitude. For this you can use Reverse geocoding which can translate the latitude & longitude into an address. You also have the option of using place_id, it is used to uniquely identify a place in Google Maps. See Places IDs. You also have the option of using the address of the place but I do not recommend it; due to the fact that there can be multiple places with the same name.
As for the properties that is available for the place, you may want to look at Place Details of Places API. This will return details like latitude,longitude, place_id, international_phone_number, opening_hours, permanently_closed, price_level, reviews etc.
Hope this will help you. Good luck!
To locate a place in google map, we need latitude and longitude.
for eg. in android ,to mark a location
static final LatLng PERTH = new LatLng(-31.90, 115.86);
Marker perth = mMap.addMarker(new MarkerOptions()
.position(PERTH));
here -31.90 and 115.86 are that places latitude and longitude respectively.
I think the logic may b same in all platforms

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.

Set location on google map

I have created one small application, where user can store his/her contacts with full address including map. Therefore I am using the Google Maps API, where user can point out his/her address.
For this I have given address fields with Country, State and City. When user entered this information, I am showing the default address on Google Maps, then the user has to drag the marker/pointer onto his/her exact location.
Now, in this case I want the zoom level of googles map to be set as per location's population.
This means if the user entered city with no mans land (less population or any desert place or any jungle place or very small area on city then zoom level should be more, so user can see proper area on map) otherwise zoom level should be less.
Can some one guide me how to do this?
This won't be possible using the Google API's alone, (I'm unsure if demographics info has been released for the US, I know it was in the works, but it certainly won't work elsewhere). You will have to find an external source to provide your demographics information for you.
The Google API's do not keep a public record of population density.
You could however be a but more tricksy and use an approximation. You could for example do a places search in the area (using an arbitrary radius), count the number of results and use this to set your zoom level (again using an arbitrary value to determine high/medium/low etc). It's a fair assumption (though still an assumption) that any area with a large number of 'places' returned will be densely populated.
You don't need to base this on the population of the location. Please check the follwing link. I think it should give you an idea of the options you have.
Google Maps API v3 - Geocoder results issue with bounds
Check both my question and my answer. You will probably want to use the viewport object.

Google Maps: Is there a way to find out whether a city has a detailed map (not StreetView)?

I have a point on a map. The point belongs to a city which doesn't have a detailed view with all the streets and buildings yet. But I hope Google will cover this city some time in the future. So I have to display map in a satellite view for now but it would be perfect if the map started to display in a standard view as soon as Google covers the city.
Is it possible to determine programmatically whether city has a detailed view with streets and buildings on Google Maps?
I solved my problem using reverse geocoding for a given point on a map. If result has a ROOFTOP location_type parameter, that means that the map contains a building at that point. Otherwise there are no buildings.