Closed VelizarVESSELINOV closed 1 year ago
@VelizarVESSELINOV Hey I know this is super old but did you ever find a good way of doing this?
@VelizarVESSELINOV Hey I know this is super old but did you ever find a good way of doing this?
I do not plan on implementing this as a permanent feature, however if anyone's curious as to how this could (sloppily) be done, this is what I did:
gmapjs.html
filterMarkers = function(category) {
for (i = 0; i < {{gmap.varname}}_markers.length; i++) {
marker ={{gmap.varname}}_markers[i];
// If is same category or category not picked
if (marker.category == category || category.length === 0) {
marker.setVisible(true);
}
// Categories don't match
else {
marker.setVisible(false);
}
}
}
build_marker_dict
function of __init__.py
, adding a "category" field like so: def build_marker_dict(self, marker, icon=None):
# type: (Union[List, Tuple], Optional[Icon]) -> Dict
marker_dict = {
"lat": marker[0],
"lng": marker[1],
"icon": icon or DEFAULT_ICON,
"category": category
}
if len(marker) > 2:
marker_dict["infobox"] = marker[2]
if len(marker) > 3:
marker_dict["icon"] = marker[3]
if len(marker) > 4:
marker_dict["category"] = marker[4]
return marker_dict
It will be nice to be able to filter by type of markers, example
Display: