Update custom controls sample and migrate to new repo#1121
Update custom controls sample and migrate to new repo#1121
Conversation
|
Here is the summary of changes. You are about to add 11 region tags.
This comment is generated by snippet-bot.
|
willum070
left a comment
There was a problem hiding this comment.
Thank you so much, this totally makes my day!! A great start, but there are a few things to clean up. Specifically there's a refactor I'd like to see done for all migrations where it makes sense (see my comments and use #1119 for reference).
Also please make sure your PR doesn't contain any changes to dist/, as that stuff gets generated automatically once your changes are merged.
| /** | ||
| * Creates a control that recenters the map on Chicago. | ||
| */ | ||
| function createCenterControl(map) { |
There was a problem hiding this comment.
Here is where the fun begins! My practice has been to refactor things to be declarative rather than generate UI programmatically. Here are the steps I'd recommend:
- Take the CSS definitions from the createCenterControl() function and move them into a new CSS style.
- Nest the button element in the gmp-map element and use the slot attribute to position it.
- Within initMap(), add code to get the button element from the HTML.
- Move the event handler for the button into initMap().
- Remove the createCenterControl() function.
- Remove the injection code on ln. 61 - ln. 68, as it's not needed now that you've got HTML.
See #1119 for reference.
Co-authored-by: William French <wfrench@google.com>
Update custom controls sample and migrate to new repo