Commit e89db22a authored by Rodrigo Tapia-McClung's avatar Rodrigo Tapia-McClung

Fix when nothing is selected and when only poly and circle intersection exists

parent ab52bb05
......@@ -238,19 +238,22 @@ map.on("click", "muni_polygon", e => {
let muniInteresects = selectedMunis.filter( el => turf.intersect(el.geom, circleGeom));
let intersectedIDs = muniInteresects.map(a => a.id);
if (intersectedIDs.length > 0) {
if (intersectedIDs.length > 0 ) { // if at least one polygons intersects circle geom
// ids not intersecting circle
let selectedIDs2 = selectedIDs.filter( id => intersectedIDs.indexOf(id) == -1 );
// depending on selected polygons, use them and geom inside circle
map.setFilter("denue",
["any",[
"match",
["get", "municipio_cvegeo"],
selectedIDs2,
// if there are polygons outside of circle intersection or use fake id to only use circle geom
selectedIDs2.length > 0 ? selectedIDs2 : ["sin-clave"],
true,
false
], ['within', circleGeom]
]
);
} else {
} else if (selectedIDs.length > 0) { // if no circle intersection but only selected polygons
map.setFilter("denue",
["all",[
"match",
......@@ -261,7 +264,18 @@ map.on("click", "muni_polygon", e => {
]
]
);
} //TODO: handle case when nothing is selected
} else if (selectedIDs.length == 0) { // if no selected polygons use fake id
map.setFilter("denue",
["all",[
"match",
["get", "municipio_cvegeo"],
["sin-clave"],
true,
false
]
]
);
}
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment