Carto coding challenge - Mini Carto library as described in https://gist.github.com/jimartincorral/d936859eaa09db025b9b7e89176a8ffb
Find an example web using this library in: https://github.com/hugo-cardenas/carto-challenge-mini-web
$ npm install https://git@github.com/hugo-cardenas/carto-challenge-mini-lib.git
Define your map container element in HTML:
<div id="map"></div>
Create the map:
const createMap = require('mini-carto-lib');
const config = {
// Config object
};
createMap('map', config);
It returns a Promise which resolves with a map object, which you can use to modify the rendered map:
createMap('map', config)
.then(map => {
const layers = map.getLayers();
layers[0].hide();
layers[0].show();
layers[1].setSQL('SELECT * FROM foo LIMIT 10');
});
Render the map specified by config
into the DOM element identified by id
.
The config spec is found here.
Returns a Promise which resolves with a map
object.
Return an array of map layer objects.
Hide this layer in the map.
Show this layer in the map.
Update the SQL code for this specific layer.
Note: only Carto layers will contain this method.