Example #1
0
        /// <summary>
        /// Converts a <see cref="MapSpan"/> to a <see cref="LatLngBounds"/>
        /// </summary>
        /// <param name="self">Self instance</param>
        /// <returns>The <see cref="LatLngBounds"/></returns>
        public static LatLngBounds ToBounds(this MapSpan self)
        {
            var southWest = GmsSphericalUtil.ComputeOffset(self.Center, self.Radius.Meters * Math.Sqrt(2), 225).ToLatLng();
            var northEast = GmsSphericalUtil.ComputeOffset(self.Center, self.Radius.Meters * Math.Sqrt(2), 45).ToLatLng();

            return(new LatLngBounds(southWest, northEast));
        }
Example #2
0
        /// <summary>
        /// Creates a <see cref="LatLngBounds"/> from a collection of <see cref="MapSpan"/>
        /// </summary>
        /// <param name="spans">The spans to get calculate the bounds from</param>
        /// <returns>The bounds</returns>
        private LatLngBounds BoundsFromMapSpans(params MapSpan[] spans)
        {
            LatLngBounds.Builder builder = new LatLngBounds.Builder();

            foreach (var region in spans)
            {
                builder
                .Include(GmsSphericalUtil.ComputeOffset(region.Center, region.Radius.Meters, 0).ToLatLng())
                .Include(GmsSphericalUtil.ComputeOffset(region.Center, region.Radius.Meters, 90).ToLatLng())
                .Include(GmsSphericalUtil.ComputeOffset(region.Center, region.Radius.Meters, 180).ToLatLng())
                .Include(GmsSphericalUtil.ComputeOffset(region.Center, region.Radius.Meters, 270).ToLatLng());
            }
            return(builder.Build());
        }