Set map bounds to circle bounds? (polyline, polygon, marker, circle) #449
Description
Hi,
Intro
I am currently building a search tool which will plot search results on a map, similar to your typical store locator. The user chooses a location (lat/lon) to search from and a radius. A database is queried for records which are within the specified radius of the user's location. These results are returned back to the browser to be plotted on a Google Map with angular-google-maps.
I am using <markers>
directive to display the results on the map. I am also using a <circle>
directive to show the search radius, setting the "center"
property to be the user's chosen location, and the "radius"
property to be the search radius.
The Problem
I would like to have the map fit to the bounds of the circle. I understand that I can set the "bounds"
property on the <google-map>
directive. However I'm not sure how I can retrieve the bounds of the circle.
Potential Solution
The google.maps.Circle class has the method getBounds()
which returns a LatLngBounds object. However I'm not sure if I'm able to access the Circle
object of the <circle>
directive in order to retrieve its bounds.
Even if I am able to retrieve the bounds of the <circle>
, I'm not sure how I would store that in a scope model in order to assign it to the <google-map>
.
Do you know how I could achieve the above using angular-google-maps?
Also Tried
I have also tried setting "fit"
to true
on the <markers>
directive. This works as expected, however because it fits the map based on the returned results, it doesn't center the map based on the initial search location, nor does it fit to the radius circle.
I want to show the search location in the center, even if the results only exist within the southern region of the radius circle. Therefore this approach doesn't achieve what I'm looking for.
Thanks