Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide people on maps when map zoom is well past their provided location precision #2201

Closed
jywarren opened this issue Feb 2, 2018 · 6 comments
Labels
help wanted requires help by anyone willing to contribute JavaScript

Comments

@jywarren
Copy link
Member

jywarren commented Feb 2, 2018

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:

$.getJSON("/api/srch/peoplelocations?srchString=100" , function(data){
if (!!data.items){
for (i = 0; i < data.items.length ; i++) {
var url = data.items[i].docUrl ;
var title = data.items[i].docTitle ;
L.marker([data.items[i].latitude , data.items[i].longitude]).addTo(map<%= unique_id %>).bindPopup("<a href=" + url + ">" + title + "</a>") ;
}
}
});
}

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

@jywarren jywarren added help wanted requires help by anyone willing to contribute JavaScript labels Feb 2, 2018
@jywarren
Copy link
Member Author

jywarren commented Feb 2, 2018

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

@sagarpreet-chadha
Copy link
Contributor

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 ?

@jywarren
Copy link
Member Author

jywarren commented Feb 5, 2018

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.

@sagarpreet-chadha
Copy link
Contributor

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

@jywarren
Copy link
Member Author

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

@jywarren jywarren added this to the Geographic features milestone Mar 31, 2020
@stale stale bot added the stale label Oct 7, 2020
@publiclab publiclab deleted a comment from stale bot Oct 8, 2020
@stale stale bot removed the stale label Oct 8, 2020
@jywarren
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted requires help by anyone willing to contribute JavaScript
Projects
None yet
Development

No branches or pull requests

2 participants