TransWikia.com

Apply a polygon filter to CartoJS 4 dataview

Geographic Information Systems Asked by BernieSF on August 9, 2020

Checking this example on CartoJS 4 documentation https://carto.com/developers/carto-js/examples/#example-filter-data-using-drawing-tools, you can apply a circle filter to a source. The problem with this is affects what the user is seeing on the loaded layer. There is a way to apply the same filter but to a dataview? That way the user can draw polygons on top of the layer to get the data without affecting the visible layer. So far the examples only shows how to apply ‘bounding box’ filters to a dataview.

One Answer

You cannot apply a polygon filter, but you can run a query against SQL API to get data from a random polygon.

Here an example: https://bl.ocks.org/alasarr/e80378614d4290b970cf25ccdb17c377

At the example, you've a layer of points, you can draw a polygon and query data that match with your polygon.

Answered by alasarr on August 9, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP