-
Notifications
You must be signed in to change notification settings - Fork 815
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
feat: Add placeId to map click events #1606
Conversation
allow disabling a "point of interest" default info window. use it by passing a boolean value to the new property isToShowDefaultInfoWindowForIcons when initializing the map. default value is true. closes issue sebholstein#1539.
When clicking on a point of interest on a map the emiting event will include the placeId of the location clicked. closes issue sebholstein#691.
Codecov Report
@@ Coverage Diff @@
## master #1606 +/- ##
==========================================
- Coverage 33.17% 33.11% -0.07%
==========================================
Files 37 37
Lines 1640 1643 +3
Branches 128 129 +1
==========================================
Hits 544 544
- Misses 1094 1097 +3
Partials 2 2
Continue to review full report at Codecov.
|
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.
The general implementation of the new feature looks good. In its current form, it is suitable for use in my own projects. Most of your changes appear to be style changes, some of which go against the Google JavaScript Style Guide. I recommend that you run the provided npm run clang:format
script and commit the resulting changes.
The two automated checks that didn't pass are both related to unit testing. The Contributing Guidelines specify that appropriate test cases should be added to any new feature. I recommend adding some unit tests to verify the new functionality that you have added.
Again, the functionality looks great. All that is left is housekeeping to improve the code quality.
packages/core/directives/map.ts
Outdated
* When this property is set to npm run buildfalse, the info window will not be shown but the click event | ||
* will still fire | ||
*/ | ||
@Input() isToShowDefaultInfoWindowForIcons: boolean = true; |
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.
The input name is rather verbose. A shorter name, such as showDefaultInfoWindow
, would be easier to understand and would avoid cluttering user code down the line.
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.
@benjcallaghan i have committed fixes to all of your comments.
Thanks
packages/core/map-types.ts
Outdated
export interface MouseEvent { coords: LatLngLiteral; } | ||
export interface MouseEvent { | ||
coords: LatLngLiteral; | ||
placeId: string; |
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.
Because some MouseEvent
objects do not have a placeId
, such as when the user clicks on a blank portion of the map, the property on the interface should be optional.
placeId: string; | |
placeId?: string; |
packages/core/directives/map.ts
Outdated
lat: event.latLng.lat(), | ||
lng: event.latLng.lng() | ||
}, | ||
placeId: null |
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.
The value for placeId
can be in-lined here without a conditional. If the Google event doesn't have that property, then it is set to undefined
, which follows the existing pattern by Google and matches the previous behavior.
placeId: null | |
placeId: (<google.maps.IconMouseEvent>event).placeId |
packages/core/directives/map.ts
Outdated
placeId: null | ||
}; | ||
// we cant use instanceOf since the IconMouseEvent is an interface | ||
if ((<any>event).placeId !== undefined && (<any>event).placeId !== null) { |
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.
The two conditions here can be simplified since both undefined
and null
are "falsy" values in JavaScript.
if ((<any>event).placeId !== undefined && (<any>event).placeId !== null) { | |
if (value.placeId && !this.isToShowDefaultInfoWindowForIcons) { |
When clicking on a point of interest on a map the emiting event will include the placeId of the location clicked. closes issue sebholstein#691. fixes for @benjcallaghan code review comments
@SebastianM What further changes do we need to make, if any, to get this approved for production use? |
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.
In addition to the marked changes, please remove all the whitespace, formatting changes, since they are outside the scope of this PR. If you want, open a separate PR with all the styling chores.
Thanks for your contribution!
When clicking on a point of interest on a map the emiting event will include the placeId of the location clicked. closes issue sebholstein#691. fixes for @doom777 code review comments
Hey @doom777 |
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.
Hey, @yosigolan thanks so much for putting in work.
Please correct the few minor whitespace changes I pointed out, and I'd be happy to test the PR out and merge into the code.
Thanks in advance!
When clicking on a point of interest on a map the emiting event will include the placeId of the location clicked. closes issue sebholstein#691. fixes for @doom777 code review comments
@doom777 |
feat: Add placeId to map click events
When clicking on a point of interest on a map the emitting event will include the placeId of the location clicked.
closes issue #691.