-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix hard failure on google maps error #2184
Conversation
Size Change: +1 kB (+0.03%) Total Size: 3.9 MB
ℹ️ View Unchanged
|
@@ -72,31 +56,25 @@ export class MapComponent | |||
// Setting to "hybrid" can increase load times and looks like the map is bugged | |||
public mapOptions: MapOptions = { mapTypeId: "satellite" }; | |||
public bounds: google.maps.LatLngBounds; | |||
private updateMap: boolean; | |||
private updateMap: boolean = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the purpose of this field, what does it do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Google maps runs the ngAfterViewChecked
method every 100ms, even with DetectChanges.OnPush
This updateMap
exists so that we don't need to run this code every 100ms
I'm looking into it now because I suspect this is something that we're doing wrong; I wouldn't expect Google to author code that continuously runs ngAfterViewChecked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh i didn't see that function.
you're right though, seems weird we're hooked into ngAfterViewChecked. Perhaps another hook is more appropriate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: ngAfterViewChecked
is due to the ViewChild
decorators for the GoogleMap
, MapInfoWindow
, and MapMarker
components
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok it seems you've tried to use a promise like a signal.
If you actually want to emit all the various states, perhaps an observeable is the right choice here.
Otherwise, your promise can return values too you know. Like Loaded
or Failed
.
I don't understand why you need SharedPromise
and I don't understand why loadAsync
isn't just
return this.loadPromise;
And embedGoogleMaps
is an async function that returns a promise. Why is that not just assigned to this.loadPromise
?
This file needs a simplicity pass.
* Fixes a bug where if Google Maps failed to embed, the entire site would hard-fail * Move the embedGoogleMaps.ts helper scripts into a DI service * Lazy load google maps to only embed when we need it for the current page (improving performance) * Asyncronously embed google maps (embedding google maps is no longer a blocking operating, improving performance and reducing the scope for bugs) * Adds loading spinner when Google maps is loading * Adds failure state when Google maps fails to load * Re-enables map component tests Fixes: #2175
Fix hard failure on google maps error
Changes
embedGoogleMaps.ts
helper scripts into a DI serviceProblems
Any problems caused by the PR that will need to be address in another PR. For example, these issues may be caused by another branch which will change how this branch functions.
Issues
Fixes: #2175
Final Checklist
npm run lint
)npm run test:all
)