Is there a way to retrieve the radius of a given location using the google API?
I want to use the above information so that when a user performs a search relevant to a location I can set the distance radius based on the size of the location instead of having a fixed radius on all searches.
Google Maps can show the perimeter of a geographic area. Nevertheless, it seems that Google has not enabled this functionality through the API.
Google Maps API V3: How to get region border coordinates (polyline) data?
Add "Search Area" outline onto google maps result
Google has started highlighting search areas in Pink color. Is this feature available in Google Maps API 3?
The Google Places API response in the Google Maps Javascript API v3 contains a viewport which is:
viewport | LatLngBounds | The preferred viewport when displaying this Place on a map. This property will be null if the preferred viewport for the Place is not known.
That can be used to calculate a radius if that is what you need or directly as the area to search.
Related
I'm looking for a way to get the default heading in the Google Maps Streetview Embed with the same accuracy/heading as the static Streetview.
For a project I'm using the Google Maps static Streetview API to create a snapshot/front facing view of an address. The way I do this is to first find the address LatLng with the Google GeoCode API, using the full address (streetname+house_number+house_number_addition+zipcode+city). With the latLng I then call the Static streetview API to fetch a snapshot of this location.
https://maps.googleapis.com/maps/api/streetview?size=900x600&location={$latLng}&key={$key}"
As you can see there is no heading param specified so the API determines the best possible heading based on the given LatLng, as specified in the API docs.
The result is spot on for 99% of the cases, in which the house is almost perfectly centered in the streetview snapshot.
The Google maps streetview embed has a very different result. The steps leading up to the creation of the embed URL are identical (find the latlng based on the full address, and use the LatLng as the location in the embedcode)
https://www.google.com/maps/embed/v1/streetview?key={$key}&location={$latLng}"
resulting in the iframe HTML
<iframe src='{https://www.google.com/maps/embed/v1/streetview?key={$key}&location={$latLng}"}' width='600' height='450' frameborder='0' style='border:0;' allowfullscreen='' aria-hidden='false' tabindex='0'></iframe>
In this case the heading or camera direction is in many (not all) cases almost facing opposite of the targeted house. Of course this can be adjusted using the heading param, but it's strange that both streetview API's differ so much in the chosen heading.
After some more digging I found the answer here. The solution is to first use the Directions API to navigate to the given location, which sets the heading facing the location. Then use the getPanoramaByLocation method of the StreetviewService to determine the correct heading.
So instead of constructing the embed code serverside, the best approach seems to create the Streetview in the frontend using the Google Maps API.
I have a set of random locations. The location set will keep changing. I would like to draw a polygon surrounding these locations.
Can this be done in Google Maps and how? The map will be displayed on a website only, no mobile api required.
It's called a convex hull. Here:
http://www.geocodezip.com/v3_map-markers_convexhull.asp
I would cite the code but it belongs to #geocodezip who is the authority on google maps and runs an excellent site of examples. I suggest you check it out.
I have to find out whether a given lat/long value is with in a circle/rectangular area whose centre is some lat/long with some fixed radius.
is there any google maps API available for that ?
You can look at the documentation - containsLocation
Here is the link:
https://developers.google.com/maps/documentation/javascript/examples/poly-containsLocation
I have a website that contains a database of places, mostly stores and small businesses, and i want to add a google map for every business on the site. I have a name and coordinates for each business, but not all of them are listed on google maps. If i make a Google Maps Embed API map like this:
https://www.google.com/maps/embed/v1/place?key=APIKEY&q=Place name
I will get a marker on that place, but if that place is not found, is it possible to make it put a marker on the coordinates provided?
I know i can just use the coordinates without any name, but in case the place is listed on google maps, querying its name instead of coordinates will display details about the place
Yes you can still place a marker as long as you have the lat and long.
You can add your business to Google Map over here.
Is there any way to id multiple polygons in Google maps v3?
Also, can you track when a polygon changes size? I wasn't clear about how to do that from the Google Maps API guide.
I want to set up a div or textbox that has the size of a polygon on creation, but changes value when the user changes the size.
I just defined my own id property, and used that - pretty simple, actually