Question - Markers in Viewport
lmorroni opened this issue · comments
Hi,
Do you have a suggested way to get a list of all markers currently visible in the viewport? Not clusters but the actual markers themselves. I need to generate a report of visible markers.
Thanks,
Larry
Hi Larry,
anycluster expands the area that is clustered from the viewport to the minimum number grid cells the viewport is in. We need this to get constant cluster positions. If we would cluster depending only on the viewport coordinates and not a fixed grid, all clusters would get new positions if the map is panned.
This leads to the following phenomenon:
anyclusters response can include markers slightly outside the viewport
In most cases, the amount of markers or clusters that are outside the viewport, but inside the grid, is very low - but still something that might affect the answer to your question.
This leads to the following opportunities:
-
- get all markers (not clusters) which are really inside the viewport (the count of all markers contained in all visible clusters can be slightly higher than this).
-
- get all markers clustered by anycluster for a specific request (also includes the markers that are outside the viewport, but inside the viewport's grid)
I think a second ajax request would be a good choice because this would maintain the performance of the map clustering. As I think that this is an enhancement, I'd implement this as a function that one can call from a django view, manipulate the data, and pass it to the website. Which one of the above do you think would be the most useable to start with?
You could call it like (as a first idea):
var anyclusterSettings = {report: {"div_id":"something", "url":"your_report_url"};
the report_url points to your view which fetches the viewport markers from anycluster (maybe cached)
Hi,
Thanks for your reply. I think option 1 below would be the way to go.
I understand what you are saying about the markers outside the visible
viewport being inside the viewport grid and I have witnessed this via
the pincount variable results. I just need to be able to run a report
that shows data for all visible markers. If markers outside the view
returned then this would lead to confusion. I may need to stop showing
the pincount since that confuses users as well.
Thanks!
Larry
biodiv mailto:notifications@github.com
April 12, 2014 at 7:10 AMHi Larry,
anycluster expands the area that is clustered from the viewport to the
minimum number grid cells the viewport is in. We need this to get
constant cluster positions. If we would cluster depending only on the
viewport coordinates and not a fixed grid, all clusters would get new
positions if the map is panned.This leads to the following phenomenon:
anyclusters response can include markers slightly outside the viewportIn most cases, the amount of markers or clusters that are outside the
viewport, but inside the grid, is very low - but still something that
might affect the answer to your question.This leads to the following opportunities:
- get all markers (not clusters) which are really inside the
viewport (the count of all markers contained in all visible
clusters can be slightly higher than this).
- get all markers clustered by anycluster for a specific request
(also includes the markers that are outside the viewport, but
inside the viewport's grid)I think a second ajax request would be a good choice because this
would maintain the performance of the map clustering. As I think that
this is an enhancement, I'd implement this as a function that one can
call from a django view, manipulate the data, and pass it to the
website. Which one of the above do you think would be the most useable
to start with?You could call it like (as a first idea):
|var anyclusterSettings = {report: {"div_id":"something",
"url":"your_report_url"};
|the report_url points to your view which fetches the viewport markers
from anycluster (maybe cached)—
Reply to this email directly or view it on GitHub
#13 (comment).
Larry Morroni
610.862.0920
http://morroni.com
I think it should be very easy to calculate 2 counts in javascript: one that contains all clustered pins, and one that contains only those that are inside the viewport.
This function is now implemented using geojson for future use. The backend is now capable of querying markers inside any type of geometry (polygon, multipolygon, circle,..)