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

Map country areas #484

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open

Map country areas #484

wants to merge 4 commits into from

Conversation

lukestanley
Copy link
Member

@lukestanley lukestanley commented Jul 22, 2024

Makes Map block able to accept a "country" property in the array of map points it processes, that show as an area, the values must be 3 letter ISO country codes.
Shading for area can be adjusted.
Custom map pin points may be set to an emoji flag.
Documentation has been updated.
A unit tests file for the block was added.

image

This should meet requirements for: #483

Copy link

vercel bot commented Jul 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kendraio-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 22, 2024 5:35pm

Copy link
Collaborator

@gsambrotta gsambrotta left a comment

Choose a reason for hiding this comment

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

Nice work and very well documented. Thank you for this, Luke.
Some minor comments here

The Map block expects incoming data to be an array of objects.
Each object represents a marker, and/or a country area. Each object can include the following properties:

- **Location-based Pin:** Provide both ``lat`` and ``long`` properties to display a pin at the specified coordinates.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please write the properties exactly as they are in the object? We do like this in all the other blocks and common way of documenting.
So in this case it would be:
customPin: explanation
lat
long
label
and so on.

Copy link
Collaborator

Choose a reason for hiding this comment

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


Optionally, include a ``label`` property for the popup label and a ``customPin`` property for custom icons (see below).

**Example: Displaying location pins**
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we keep the format of "Examples" as chapter title and then the examples name as subtitle?
Like we do here: https://kendraio-app.readthedocs.io/en/latest/workflow/blocks/actions.html

"type": "mapping",
"mapping": "data[?recovered > `20`].{ lat: lat, long: long, label: join(' ', [to_string(recovered), 'recovered in', combinedKey][? @ != null]) }"
}
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not clear to me. Where this countryStyle object should stay? Is another property of the object containing the country, the lat and long? Or where it stays?


Example map block configuration:
**Example: Displaying country areas**
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest getting rid of this title and the countryStyle code and directly write the complete code example.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would say you can even write an example with the customPin. Is clear enough, I don't think it needs two separate example for it.


**Example: Custom pin icons with emojis**

This example uses emojis as custom pin icons for specific locations:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am confuse, I don't see any difference between this customPinvalue and previous example customPin value

component = fixture.componentInstance;
});

it("should create", () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

it should create... what? :)

lat: `51.5074`,
long: `-0.1278`,
label: "London",
customPin: "📍",
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't this be plain text?

@@ -28,23 +29,92 @@ contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA
markerClusterData = [];
markerClusterOptions = {};

// Country GeoJSON provider base URL
countryProviderBaseURL = 'https://raw.githubusercontent.com/AshKyd/geojson-regions/main/public/countries/50m/';
Copy link
Collaborator

Choose a reason for hiding this comment

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

These are static values, right?
Can you please write them in uppercase and outside the component? So they do not get re-render/re-computed


// In-memory cache for country GeoJSON data
countryCache: { [key: string]: any } = {};

onConfigUpdate(config: any) {
this.height = get(config, 'height', 500);
set(this.options, 'zoom', get(config, 'zoom', 8));
const latln = get(config, 'latlng', [51.505, -0.09]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where do these static values come from? 500, 8 and [51,505, -0,09] Would be great to know. Maybe add a comment on the code?

});
}

if (lat && long) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it reasonable to create an object without LAT and LONG? Aren't they indispensable information to work with a map?

Copy link
Member Author

Choose a reason for hiding this comment

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

A country is an area, and so is a LAT and LONG, it is just smaller, as a point.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Honestly @lukestanley I do not understand this comment. Can you help me understand better what do you mean?
My question is: Can map object exist and be valid without a LAT and LONG? If yes, how come?

Copy link
Collaborator

@CodeKrakken CodeKrakken left a comment

Choose a reason for hiding this comment

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

Very nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants