Reporting
lmorroni opened this issue · comments
Hi,
I am interested in giving my users the ability to download reports in CSV format. I am able to do this with a standard call to a view using Django. I tried to do this via your anycluster.getAreaContent javascript function but am having issues. I would prefer to not have this be an AJAX call and just call the view directly which would initiate the download. The problem is that there are a number of variables that I need for this request such as geoJson, grid, zoom, and filters. I have not discovered an elegant way to pass these variables to my view. My plan was to stuff these variables in a hidden input form field and update them during each loadEnd() event. This seems clunky but doable. Before I go down that road, I am wondering if you have any alternative suggestions.
Thanks,
Larry
We could also do this using Django's request.session
as this is not a new clustering event. anycluster already stores some variables in the session and it would be easy to add geoJson etc. Your view URL would simply be something like site.org/getreport/
with a non-ajax GET
request - without any parameters. All parameters are then grabbed from the django session within the view. If you just want to get all viewport markers as a .csv it would suffice to store the viewport gejson in the session. If you want some clustering information we need to add grid, zoom etc.
If you want to try the session-approach just let me know what the report should contain and I will update the session parameters accordingly.
All I need is the geoJson since my report will be all markers in the current viewport.
I see that you added request.session['geojson']
. Thanks! What function from MapClusterer.py should I be calling to get all markers for the current geojson viewport?
Larry
The easiest way is to call loadAreaContent
from anycluster.views
since the latest update which will return a queryset of all markers.