Skip to content
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

Merged
8 commits merged into from
Jun 3, 2019
Merged

Conversation

yosigolan
Copy link
Contributor

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.

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
Copy link

codecov bot commented Feb 24, 2019

Codecov Report

Merging #1606 into master will decrease coverage by 0.06%.
The diff coverage is 0%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
packages/core/directives/map.ts 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 49890c5...d6d5a6a. Read the comment docs.

Copy link

@benjcallaghan benjcallaghan left a 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.

* 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;

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.

Copy link
Contributor Author

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/directives/map.ts Outdated Show resolved Hide resolved
export interface MouseEvent { coords: LatLngLiteral; }
export interface MouseEvent {
coords: LatLngLiteral;
placeId: string;

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.

Suggested change
placeId: string;
placeId?: string;

lat: event.latLng.lat(),
lng: event.latLng.lng()
},
placeId: null

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.

Suggested change
placeId: null
placeId: (<google.maps.IconMouseEvent>event).placeId

placeId: null
};
// we cant use instanceOf since the IconMouseEvent is an interface
if ((<any>event).placeId !== undefined && (<any>event).placeId !== null) {

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.

Suggested change
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
@benjcallaghan
Copy link

@SebastianM What further changes do we need to make, if any, to get this approved for production use?

Copy link

@ghost ghost left a 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!

package.json Outdated Show resolved Hide resolved
packages/core/directives/map.ts Outdated Show resolved Hide resolved
packages/core/directives/map.ts Outdated Show resolved Hide resolved
@ghost ghost added the needs: changes label May 30, 2019
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
@yosigolan
Copy link
Contributor Author

Hey @doom777
fixed all your comments.

Copy link

@ghost ghost left a 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!

packages/core/directives/map.ts Outdated Show resolved Hide resolved
packages/core/directives/map.ts Outdated Show resolved Hide resolved
packages/core/directives/map.ts Outdated Show resolved Hide resolved
packages/core/directives/map.ts Outdated Show resolved Hide resolved
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
@yosigolan
Copy link
Contributor Author

@doom777
Done

@ghost ghost added needs: review and removed needs: changes labels Jun 2, 2019
@ghost ghost self-assigned this Jun 2, 2019
@ghost ghost merged commit 34f651b into sebholstein:master Jun 3, 2019
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants