Plots2: Hide people on maps when map zoom is well past their provided location precision

Created on 2 Feb 2018  路  6Comments  路  Source: publiclab/plots2

We encourage people to "blur" their location with leaflet-blurred-location, which:

  1. truncates their latitude + longitude to, for example, 41.13 instead of 41.13256 to reduce location precision
  2. adds the location:blurred tag if they want to blur their location

We display people on maps on this template: https://github.com/publiclab/plots2/blob/master/app/views/map/_peopleLeaflet.html.erb

Which shows up at http://publiclab.org/people

Let's not display their marker if you zoom too far in. So, reading here for the relationship between zoom and precision, let's modify this block of code to not display tags if their lat/lon precision is quite low and we're zoomed in quite far:

https://github.com/publiclab/plots2/blob/4e16a68138d8465cd8b604a8717f0943c7ab51b6/app/views/map/_peopleLeaflet.html.erb#L17-L26

For a listed correlation of zoom and precision so we know when to make this distinction, see:

https://github.com/publiclab/leaflet-blurred-location/blob/e802cdf2cd4d8c7be69cca69f96327f4bc9a1346/src/core/gridSystem.js#L12-L17

JavaScript help wanted

All 6 comments

@sagarpreet-chadha or @mridulnagpal -- perhaps you'd be interested here? What do you think, in any case?

Hi @jywarren , i was thinking of calling a function :
map.on('zoomend', function() {
});
and
getting the current zoom level : currentZoom = map.getZoom();
and traveling the array of data-items containing people info . and removing them if the degree of precision (number of digits after decimal) is less than the current zoom level using :
marker.remove();
What do you think ?

This sounds pretty good -- there may also be a getCurrentBounds() method you could use? or getCenter?

We could actually clear all markers and add new ones, doing both on the moment of getting a response from the server.

Hi @jywarren , makes sense . I would like to work on this :-)

I think this is solved in the latest LBLD! https://github.com/publiclab/leaflet-blurred-location-display/pull/102/ but we should confirm by testing at https://publiclab.org/map as soon as we republish that.

My reading was that https://github.com/publiclab/leaflet-blurred-location-display/pull/102/ shows popups for grid (blurred) people. I think that should solve it, as we would no longer show points for blurred locations anyways.

Was this page helpful?
0 / 5 - 0 ratings