-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 module @deck.gl/carto #4925
Conversation
Examples moved to |
@@ -0,0 +1,8 @@ | |||
Pure js demo for CARTO layers | |||
|
|||
### Usage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This demo requires a Mapbox token. Either add instructions for acquiring and providing a token (see README of other mapbox examples), or remove the mapbox dependency (preferred for a "minimal" example)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really since we're using CARTO's basemaps and they are free
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the mapbox code in this example then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still use Mapbox GL but tiles are provided by CARTO, so I think we can use Mapbox GL without a token.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you prefer to have the example without the basemap to make it simpler? I just did because it looks better with the basemap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, it's fine then
<html> | ||
<head> | ||
<!-- deck.gl standalone bundle --> | ||
<script src="https://unpkg.com/deck.gl@^8.1.0/dist.min.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will need to include the carto module from CDN here.
As the number of submodules grow, we have paused adding new modules into the main bundle to prevent bloating its size with unnecessary functionalities, unless it can be justified for most common use cases. For example, the arcgis module is not part of the main bundle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I've kept it linked against ^8.1.0 just to allow an easy replace 😄
modules/carto/package.json
Outdated
"prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env.dev" | ||
}, | ||
"dependencies": { | ||
"@deck.gl/geo-layers": "^8.2.7", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a peerDependency
docs/api-reference/carto/overview.md
Outdated
```bash | ||
npm install deck.gl | ||
# or | ||
npm install @deck.gl/core @deck.gl/layers @deck.gl/carto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
geo-layers
## Install package | ||
|
||
```bash | ||
npm install deck.gl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this to work the new module must be added to modules/main
's package.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're not going to include in the bundle I think it's clearer to keep it outside the main module. Let me know otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deck.gl can include all submodules as dependency. This makes installation easier and has no direct impact on bundle size unless the user references a specific API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
To use pre-bundled scripts: | ||
|
||
```html | ||
<script src="https://unpkg.com/deck.gl@^8.2.0/dist.min.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add carto bundle
To use pre-bundled scripts: | ||
|
||
```html | ||
<script src="https://unpkg.com/deck.gl@^8.2.0/dist.min.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add carto bundle
Optional. A string pointing to a unique attribute at the result of the query. A unique attribute is needed for highlighting a feature split across two or more tiles. | ||
|
||
|
||
##### `credentials` (Object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the equivalent of using setDefaultCredentials
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the same but for each layer. It's there to support layers from different CARTO users, so you can merge in the same map datasets of two users. It's quite common when you use a public dataset with a private one.
const BQ_TILEJSON_ENDPOINT = 'https://us-central1-cartobq.cloudfunctions.net/tilejson'; | ||
|
||
const defaultProps = { | ||
...CartoLayer.defaultProps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unnecessary. defaultProps
is automatically merged with that of the parent class.
} | ||
|
||
renderLayers() { | ||
if (!this.state.tilejson) return []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return null
is fine
data: this.state.tilejson.tiles | ||
}; | ||
|
||
return new MVTLayer(props); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more efficient:
new MVTLayer(this.props, this.getSubLayerProps({
id: 'mvt',
data: this.state.tilejson.tiles
}));
|
||
const defaultProps = { | ||
...mapsApiProps, | ||
...CartoLayer.defaultProps, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
Changes applied 😄 |
|
||
<!-- or --> | ||
<script src="https://unpkg.com/@deck.gl/core@^8.0.0/dist.min.js"></script> | ||
<script src="https://unpkg.com/@deck.gl/layers@^8.2.0/dist.min.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing geo-layers
|
||
<!-- or --> | ||
<script src="https://unpkg.com/@deck.gl/core@^8.0.0/dist.min.js"></script> | ||
<script src="https://unpkg.com/@deck.gl/layers@^8.2.0/dist.min.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing geo-layers
Co-authored-by: Víctor Velarde <victor.velarde@gmail.com> Co-authored-by: Javier Aragón <jaragon@cartodb.com>
I closed by mistake sorry |
Background
Deck.gl is today the preferred/official library for CARTO to build Location Intelligence apps. We consider that the best option for the future is to be part of Deck.gl family and we've created @deck.gl/carto for this 😄 .
Why a module inside deck.gl repo? It's a more collaborative approach. The closer to Deck.gl, the better. We want our engineers in this ecosystem rather than working on a wrapper or an external module.
We've included some examples at
examples/carto
but was not clear for us to find the right place. Feel free to suggest another location even if you consider it shouldn't be part of this repo.This module provides two layers:
Change List
modules/carto
examples/carto
test/modules/carto
docs/api-reference/carto