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

Carto: fetchMap to support custom basemaps #8856

Merged
merged 17 commits into from
May 14, 2024

Conversation

zbigg
Copy link
Collaborator

@zbigg zbigg commented Apr 30, 2024

Support for custom and google basemaps in fetchMap.

Change List

  • Carto: fetchMap to support custom and google basemaps
  • Carto: tests/apps/carto-map: support for custom and google basemaps

@zbigg zbigg force-pushed the zbigg/carto-fetchmap-custombasemaps branch from f03cd54 to e683c7b Compare April 30, 2024 11:01
@zbigg zbigg force-pushed the zbigg/carto-fetchmap-custombasemaps branch from c794f07 to 0f04eb6 Compare April 30, 2024 13:11
'basemap-tile-source': {
type: 'raster',
tiles: [basemap.settings.url],
tileSize: 256
Copy link
Collaborator

Choose a reason for hiding this comment

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

256 seems like a pretty small tile size, is that correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is some magic number that we agreed upon and that works well for most sources we tested.

Anyway, i think we should make it confiruable.
I'll try to make it part of protocol, so it's already part of keplerMapConfig and we don't have to hardcode it here.

Good point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Finally, i've decided that it's better to keep whole style, so app that generates keplerMapConfig has complete control over what style is in basemap (as side-effect, we don't need code that generates style in this module).

@zbigg zbigg force-pushed the zbigg/carto-fetchmap-custombasemaps branch from 4d038e5 to bb64b83 Compare April 30, 2024 15:34
@zbigg zbigg requested a review from felixpalmer May 6, 2024 11:25
@zbigg zbigg force-pushed the zbigg/carto-fetchmap-custombasemaps branch 2 times, most recently from 4972f03 to 7adbf11 Compare May 6, 2024 13:37
@coveralls
Copy link

coveralls commented May 6, 2024

Coverage Status

coverage: 89.841% (+0.01%) from 89.829%
when pulling 1be5fc6 on zbigg/carto-fetchmap-custombasemaps
into d504327 on master.

@zbigg zbigg force-pushed the zbigg/carto-fetchmap-custombasemaps branch 2 times, most recently from b709e7a to 4960483 Compare May 6, 2024 13:49
@@ -90,9 +90,13 @@ When the map was last updated.

The [view state](../../developer-guide/views.md#view-state).

#### `mapStyle` (string) {#mapstyle}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Old mapStyle was actually an object with various internal properties (like styleType - an actual id of style).

New api is more robust and thus i propose to completly hide mapStyle in documentation.

(it's still returned for backwards compatibility, but it can be considered deprecated now)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm good hiding it! Shouldn't we also remove it or comment it from example in line 27?

I understand the API still returns it for compatibility but using it in the example without context looks confusing to me

@zbigg zbigg force-pushed the zbigg/carto-fetchmap-custombasemaps branch from 4960483 to fc64562 Compare May 6, 2024 13:53
@zbigg zbigg marked this pull request as ready for review May 6, 2024 13:54
@zbigg zbigg force-pushed the zbigg/carto-fetchmap-custombasemaps branch from fc64562 to f8ec0c8 Compare May 6, 2024 13:58
modules/carto/src/api/basemap.ts Show resolved Hide resolved
modules/carto/src/basemap.ts Outdated Show resolved Hide resolved
modules/carto/src/basemap.ts Outdated Show resolved Hide resolved
@zbigg zbigg force-pushed the zbigg/carto-fetchmap-custombasemaps branch from cbc6838 to 9291c3f Compare May 7, 2024 07:33
@zbigg zbigg requested a review from donmccurdy May 7, 2024 07:33
modules/carto/src/api/basemap.ts Show resolved Hide resolved
modules/carto/src/basemap.ts Outdated Show resolved Hide resolved
modules/carto/src/basemap.ts Outdated Show resolved Hide resolved
modules/carto/src/basemap.ts Outdated Show resolved Hide resolved
modules/carto/src/basemap.ts Outdated Show resolved Hide resolved
modules/carto/src/api/basemap.ts Outdated Show resolved Hide resolved
modules/carto/src/api/basemap.ts Outdated Show resolved Hide resolved

if (visibleLayerGroups && someLayerGroupsDisabled(visibleLayerGroups)) {
try {
const originalStyle = await fetch(styleUrl, {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than using fetch directly, use requestWithParameters if possible along with an APIErrorContext

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

requestWithParameters does lots of things, like passing ?v= (deck version), falling back to POST not allowing setting mode.

I guess that using just fetch is simpler than artificially extending requestWithParameters to become another fetch-like univeral API.

(added usage of errorContext though)

Copy link
Collaborator

Choose a reason for hiding this comment

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

The other major thing requestWithParameters provides is caching of repeated requests, but in all the current examples this doesn't matter and we only call fetchMap once, so I think it's optional here. 👍🏻

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, we do have browser cache already. If we really want to use current cache, i would factor-it-out as separate "fetchWithCache" (and only with cache), but without carto-specific features (?v=..., fallback to POST ...),

Copy link
Collaborator Author

@zbigg zbigg May 9, 2024

Choose a reason for hiding this comment

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

And when trying to see how requestWithParameters can be adapted/simplified, i've found that its cache is not-configurable and doesn't have any means to clear it - i think we should improve it.

Anyway i guess that in current state of affair it's better to rely on browser cache.

@zbigg zbigg requested a review from felixpalmer May 8, 2024 12:37
@zbigg zbigg force-pushed the zbigg/carto-fetchmap-custombasemaps branch from de1954c to b1eec58 Compare May 8, 2024 14:40
Copy link
Collaborator

@donmccurdy donmccurdy left a comment

Choose a reason for hiding this comment

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

Thanks for the additional unit tests!

modules/carto/src/api/parse-map.ts Show resolved Hide resolved

if (visibleLayerGroups && someLayerGroupsDisabled(visibleLayerGroups)) {
try {
const originalStyle = await fetch(styleUrl, {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The other major thing requestWithParameters provides is caching of repeated requests, but in all the current examples this doesn't matter and we only call fetchMap once, so I think it's optional here. 👍🏻

@zbigg zbigg force-pushed the zbigg/carto-fetchmap-custombasemaps branch 3 times, most recently from 8171205 to bf1d5e5 Compare May 10, 2024 09:19
@zbigg zbigg force-pushed the zbigg/carto-fetchmap-custombasemaps branch 5 times, most recently from f37124c to 0fda237 Compare May 13, 2024 15:35
Copy link
Collaborator

@donmccurdy donmccurdy left a comment

Choose a reason for hiding this comment

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

Added a few optional suggestions, then LGTM, thanks!

docs/api-reference/carto/basemap.md Outdated Show resolved Hide resolved
modules/carto/src/api/basemap.ts Show resolved Hide resolved
modules/carto/src/api/types.ts Outdated Show resolved Hide resolved
modules/carto/src/api/types.ts Outdated Show resolved Hide resolved
modules/carto/src/index.ts Outdated Show resolved Hide resolved
@zbigg zbigg force-pushed the zbigg/carto-fetchmap-custombasemaps branch 3 times, most recently from 4c0969b to bf40a2a Compare May 13, 2024 16:25
@zbigg zbigg force-pushed the zbigg/carto-fetchmap-custombasemaps branch from bf40a2a to 1be5fc6 Compare May 14, 2024 12:56
@donmccurdy donmccurdy merged commit 341b753 into master May 14, 2024
4 checks passed
@donmccurdy donmccurdy deleted the zbigg/carto-fetchmap-custombasemaps branch May 14, 2024 13:04
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.

5 participants