@@ -40,14 +40,22 @@ export class FakeLatLng implements LatLng {
4040 }
4141}
4242
43+ function isLatLngBoundsLiteral ( bounds : LatLngBounds | LatLngBoundsLiteral ) :
44+ bounds is LatLngBoundsLiteral {
45+ return ( typeof ( bounds as LatLngBoundsLiteral ) . north === 'number' ) ;
46+ }
47+
4348/**
4449 * A fake `LatLngBounds` class for testing purposes, that does not depend on the
4550 * `google.maps.LatLngBounds` constructor loaded by the API.
4651 */
4752export class FakeLatLngBounds implements LatLngBounds {
48- constructor (
49- private readonly boundsLiteral :
50- LatLngBoundsLiteral = { north : 0 , south : 0 , east : 0 , west : 0 } ) { }
53+ constructor ( private readonly boundsLiteral : LatLngBoundsLiteral = {
54+ north : - 90 ,
55+ south : 90 ,
56+ east : - 180 ,
57+ west : 180
58+ } ) { }
5159
5260 getNorthEast ( ) : LatLng {
5361 return new FakeLatLng ( this . boundsLiteral . north , this . boundsLiteral . east ) ;
@@ -58,6 +66,15 @@ export class FakeLatLngBounds implements LatLngBounds {
5866 toJSON ( ) : LatLngBoundsLiteral {
5967 return this . boundsLiteral ;
6068 }
69+ union ( other : LatLngBounds | LatLngBoundsLiteral ) : LatLngBounds {
70+ const { north, south, east, west} = this . boundsLiteral ;
71+ const otherLiteral = isLatLngBoundsLiteral ( other ) ? other : other . toJSON ( ) ;
72+ this . boundsLiteral . north = Math . max ( north , otherLiteral . north ) ;
73+ this . boundsLiteral . south = Math . min ( south , otherLiteral . south ) ;
74+ this . boundsLiteral . east = Math . max ( east , otherLiteral . east ) ;
75+ this . boundsLiteral . west = Math . min ( west , otherLiteral . west ) ;
76+ return this ;
77+ }
6178
6279 contains ( latLng : LatLng | LatLngLiteral ) : boolean {
6380 throw new Error ( 'contains is not implemented' ) ;
@@ -83,7 +100,4 @@ export class FakeLatLngBounds implements LatLngBounds {
83100 toUrlValue ( precision ?: number ) : string {
84101 throw new Error ( 'toUrlValue is not implemented' ) ;
85102 }
86- union ( other : LatLngBounds | LatLngBoundsLiteral ) : LatLngBounds {
87- throw new Error ( 'union is not implemented' ) ;
88- }
89103}
0 commit comments