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][PoiMap][SC-43161] Show popup on feature click #186

Merged

Conversation

KevinFabre-ods
Copy link
Contributor

@KevinFabre-ods KevinFabre-ods commented Sep 5, 2023

Summary

The goal for this PR is to show popup on the map after a feature has been clicked.

(Internal for Opendatasoft only) Associated Shortcut ticket: sc-43161.

Screenshot 2023-09-05 at 18 01 21

Changes

Poi map can now display popup when a feature is clicked.

To do so, a popup config object must be defined in a layer.

{
 ...layerConfig, 
 popup: {
    display: 'sidebar', // or 'tooltip'
    getContent: (id: GeoJSONFeature['id'], properties?: GeoJsonProperties) => 'my popup content'; 
   }
}

The SDK provides only a skeleton (positioning and content container style) for the popup.
Popup content comes from the result of getContent.

Also when interaction is switch off:

  • The view box is reset to the bbox
  • The popup is closed

Breaking Changes

none

To be tested

  • Try to use multiples sources (from different types) and layers
  • Try to used asynchronous calls to define the popup content
  • All props changes should be taken into consideration by the map

Review checklist

  • Description is complete
  • Commits respect the Conventional Commits Specification
  • 2 reviewers (1 if trivial)
  • Tests coverage has improved
  • Code is ready for a release on NPM

@KevinFabre-ods KevinFabre-ods added the enhancement New feature or request label Sep 5, 2023
@KevinFabre-ods KevinFabre-ods force-pushed the feature/create-poi-map-type branch from 70f6134 to 79fde96 Compare September 7, 2023 08:44
@KevinFabre-ods KevinFabre-ods force-pushed the feature/sc-43161/sdk-show-tooltip branch from cf41be0 to 465095f Compare September 8, 2023 07:09
@KevinFabre-ods
Copy link
Contributor Author

@RafaelSzmarowski and @wmai Sorry, I didn't realize my latest rebase broke the commit history.

Now this PR also only changes related to the popup 😉

@KevinFabre-ods KevinFabre-ods force-pushed the feature/create-poi-map-type branch from e056b1b to 7945831 Compare September 18, 2023 08:53
@KevinFabre-ods KevinFabre-ods force-pushed the feature/sc-43161/sdk-show-tooltip branch from 78f2f2a to 00979f4 Compare September 18, 2023 09:10
Copy link
Contributor

@etienneburdet etienneburdet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really clean! The map and maprender implem look really nicer, easier to read and more stable.

There are just two little things I'd rather do without: the queue mechanism and the .bind(this). This are pattern I'm not sure everybody in the future will know. Moving to a Svelte component should solve that, while leveraging 99% of this code (this is for another PR).

The popup I feel like could be done as a mix of maplibre'spopup or HTML (especially if we want to support more "sidebar" stuff, like next to the map).

Anyways, these comments are a bit more far fetch and doesn't block merge imo. I'll approve if you want to leave it like this.

@KevinFabre-ods
Copy link
Contributor Author

KevinFabre-ods commented Sep 19, 2023

There are just two little things I'd rather do without: the queue mechanism and the .bind(this). This are pattern I'm not sure everybody in the future will know. Moving to a Svelte component should solve that, while leveraging 99% of this code (this is for another PR).

👍
Let's make a ticket where we save all technical / refactor ideas we have for the Map components

➡️ https://app.shortcut.com/opendatasoft/story/43544

@wmai wmai force-pushed the feature/sc-43161/sdk-show-tooltip branch from c7d9d4b to 80265d5 Compare September 19, 2023 19:45
@KevinFabre-ods KevinFabre-ods force-pushed the feature/sc-43161/sdk-show-tooltip branch from 8a46de5 to 59ea8cf Compare September 21, 2023 10:28
Copy link
Contributor

@RafaelSzmarowski RafaelSzmarowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ! Nice work

@KevinFabre-ods KevinFabre-ods force-pushed the feature/sc-43161/sdk-show-tooltip branch from 69303d9 to 6487c64 Compare September 21, 2023 17:05
@KevinFabre-ods
Copy link
Contributor Author

Before merge I'll do a squash to keep only two commits:

@KevinFabre-ods KevinFabre-ods force-pushed the feature/sc-43161/sdk-show-tooltip branch from 6487c64 to 712b410 Compare September 21, 2023 17:11
@KevinFabre-ods KevinFabre-ods force-pushed the feature/sc-43161/sdk-show-tooltip branch from 712b410 to ab8a82b Compare September 22, 2023 07:35
@KevinFabre-ods KevinFabre-ods merged commit 2d2b015 into feature/create-poi-map-type Sep 22, 2023
4 checks passed
@KevinFabre-ods KevinFabre-ods deleted the feature/sc-43161/sdk-show-tooltip branch September 22, 2023 08:11
@KevinFabre-ods KevinFabre-ods mentioned this pull request Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants