question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Related with https://github.com/CartoDB/cartoframes/pull/586

Context

We want to change how we currently use the different layers we have:

  • QueryLayer
  • LocalLayer
  • Layer

First Approach

We’ve thought the following solution as a starting point to address this issue. We (backend team) are already working on a Dataset class. This class is going to handle local/remote datasets, but for this issue, I’m going to talk about it as a black box.

Since a Dataset is one of the source types we’ve in CARTO VL, we could have, additionally a SQL or Query class and a GeoJSON class. These clases aren’t our priority for this task at this point, but let’s just imagine we’ll have these “source” classes.

Each layer will have a source class. We’d have a main Layer class, that will receive this source class and a context (we’ll talk later about the contexts).

Then, we’d have three classes that’d inherit from Layer: PointLayer, LineLayer and PolygonLayer. What’s the advantage of having a class per geometry type? First, that we know at first glance the geometry of the layer. But also, that we could implement specific helper methods depending on the geometry, and that’d be very cool.

  • Contexts TBD

It’d be useful to provide a context per source, so you can combine both local and remote datasets, for instance. By declaring the context in the map, this is the context the layer would use, but you’d be able to use an specific context for a layer.

For example:

vl.Map([
      vl.PointLayer('dataset_1'),
      vl.PolygonLayer('dataset_2')
   ],
   context=context
)
vl.Map([
      vl.PointLayer('SELECT * FROM dataset_1 WHERE cat = "cat"'),
      vl.PolygonLayer(vl.GeoJSON('file_name.geojson'))
   ],
   context=context
)

To Do

Note: Front + Back should be involved in this task

  • Refactor base Layer class
  • ~Create PointLayer, LineLayer and PolygonLayer~ ❄️
  • Define how to integrate the Source (Dataset)
  • Create SQL & GeoJSON sources

Other ToDos moved to https://github.com/CartoDB/cartoframes/issues/629

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
oleurudcommented, Apr 30, 2019

After the yesterday talk, @elenatorro and I have talked and we thought there are 2 different tasks/parts in this issue:

  • the VL way: the user has the data ready in the database or in a geoJSON/mvt file and the user wants to render a map with vl.source.SQL, vl.source.GeoJSON, …
  • the dataframe way: the user wants to make things over the data (using Pandas) and then render a map with the data. To do this, we have 2 options:
    • the user makes over the data (pandas or other ways), then upload the data to CARTO and finally use the VL way to render the map. To do this, if I am not wrong, we don’t have to integrate anything between backend and frontend.
    • the user makes things over the data (pandas) and then the user has a way to send the pandas.DataFrame to VL. To do this, we have to integrate backend and frontend (find a way to send a pandas.DataFrames to VL). The yestarday proposal was talking about this case, because I think having a full local way to render a map is powerful. I want to talk about it with @javitonino & @alrocar. But of course, any feedback is welcome.
1reaction
elenatorrocommented, Apr 24, 2019

what is the dataframe source?

From CARTOFrames documentation, it’s a GeoDataFrame --> http://geopandas.org/reference/geopandas.GeoDataFrame.html

keep it simple for now and expand in the future

I’m ok with this, let’s freeze Create PointLayer, LineLayer and PolygonLayer for now. Just pointing that these layers would be a syntax sugar for the Layer class, they wouldn’t require a lot of extra implementation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Layer | API Reference | ArcGIS API for JavaScript 3.42
Fires when the layer visibility has been changed, and returns an object with a Boolean visible property containing the new visibility value of...
Read more >
Scripting API: GameObject.layer - Unity - Manual
To add or view a layer, click the Layout button in the top-right of the Editor window. // Put the game object in...
Read more >
Layers | Maps JavaScript API - Google Developers
The Maps JavaScript API manages the presentation of objects within layers by rendering ... Layers may also alter the presentation layer of the...
Read more >
Change layer order - Esri Community
I'm trying to implement functionality so the user can change the order of layers. My "move-layer-up" functionality works but I cannot get the....
Read more >
How to change color of a layer in ArcGIS Javascript API by ...
I want to change layer color with every click of a button. So far I have been able to do lots working with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found