publiclab / leaflet-blurred-location-display

A library to display points which have been "blurred" for privacy with leaflet-blurred-location
https://publiclab.github.io/leaflet-blurred-location-display/examples/index.html
GNU General Public License v3.0
11 stars 12 forks source link

Adding features to leaflet blurred location display (needs breaking up into separate issues) #9

Closed mridulnagpal closed 5 years ago

mridulnagpal commented 6 years ago

@jywarren Shall we extend this as well. Can you create some issues, I would love to work on this!!

jywarren commented 6 years ago

Yes, let's do! Are there some we can copy over from the big planning issue in leaflet-blurred-location?

I have one: add the ability to re-center the map via a geocoding search field. It could be almost identical to the input system, but just recenter the map of displayed locations. Make sense?

Also 2b on this has a lot: https://github.com/publiclab/plots2/issues/1416

On Sat, Mar 3, 2018 at 12:10 AM, Mridul Nagpal notifications@github.com wrote:

@jywarren https://github.com/jywarren Shall we extend this as well. Can you create some issues, I would love to work on this!!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/leaflet-blurred-location-display/issues/9, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJwj_0s7NWrc4Rz1NFudQjAhuu2Ktks5taiXHgaJpZM4SayPc .

mridulnagpal commented 6 years ago

@jywarren Can you give an example?

jywarren commented 6 years ago

Sure! Basically imagine using this library over at http://publiclab.org/people -- and imagine you want to enter Kenya and see mostly people around Kenya. There could be a search text input to type "kenya" and just like in the location input form for adding to your profile, it could autocomplete and show suggestions like "Nairobi, Kenya" for example. If you clicked that, it'd recenter the map and zoom in on Nairobi.

Make sense? Thanks!!!

mridulnagpal commented 6 years ago

Isn't something like this already being done in leaflet blurred location?

mridulnagpal commented 6 years ago

@jywarren Can you give a code example?

jywarren commented 6 years ago

^ yes, it is very similar, except that we are doing this where we are displaying a list of locations, rather than inputting a location.

@sagarpreet-chadha is working on a similar feature and perhaps this could be approached collaboratively: https://github.com/publiclab/plots2/pull/2585

We want this feature both for display of blurred locations, and for general maps on PublicLab.org, so can you two discuss where you think it best to implement it so it appears in both? If it's pretty simple code we can just include it in multiple places, but let's think through the advantages of where we could implement this cleanly. Thanks!!

sagarpreet-chadha commented 6 years ago

Hi @mridulnagpal !

I think we have various maps (including inline maps) on our website , so i think lets create a new library or may be use this library to create a library such that we can display all maps using this library only AND each map having its own unique feature like :

Basically making all different features in a library and giving the developer/end-user the options to use any combination of these features . Makes sense ?

What do you think ?

mridulnagpal commented 6 years ago

@jywarren Let's continue with this, shall we?

mridulnagpal commented 6 years ago

@jywarren Any views?

jywarren commented 6 years ago

Sorry Mridul! Been traveling (again!). Looking over this now.

jywarren commented 6 years ago

So, the basic function is:

to display a collection of blurred locations (generated for example with Leaflet.BlurredLocation) at varying zoom levels.

When zooming to higher zoom levels, blurrier locations will not be shown, if they are not at a high enough precision to be useful. For example:

When zoomed in to level _____, locations with 0.000 or better precision will be shown.

But when zooming further to level ____, locations with 0.0000 may be hidden, since they may likely fall outside the viewport.

(reference https://github.com/publiclab/leaflet-blurred-location/issues/98)

I like what @sagarpreet-chadha is suggesting -- i think the ability to search the map is key.

jywarren commented 6 years ago

So does this make sense? That in this library, as you zoom in, some locations appear only within some zoom levels, that are close to the precision they were entered in? If they have lots of precision, they might appear in many zoom levels, but if they are very imprecise (highly blurred), they would be hidden once you zoom in too far.

We could write a test to check for this -- so it would start the map up, go to a certain zoom level, and check what's visible, then zoom in further and check again, for 3 or 4 zoom levels. Then we could write the functions of this library to ensure that the markers are properly displayed for those given zoom levels.

@sagarpreet-chadha and @stefannibrasil and @milaaraujo are working on API queries that may also be used to populate this map on the Public Lab website. @sagarpreet-chadha can help explain how it was done to 'refresh on drag' with a new query to the API on features like this:

https://publiclab.org/wiki/inline-maps

(although those don't seem to be refreshing?)

Another task might be to add a "loading" indicator -- a spinner -- while map refreshes are occurring, so you know it's still loading.

sagarpreet-chadha commented 6 years ago

Hi @jywarren ...dynamic fetching of new data on zooming or panning is still not solved in this issue https://github.com/publiclab/plots2/issues/1934 (and not done by me 😄) .

Lets confirm if @stefannibrasil and @milaaraujo are working on it ❓
Else i will start work on it 👍 👍 👍

Thanks !

sagarpreet-chadha commented 6 years ago

I have done that in leaflet-environmental-layers as of now 😄 .

mridulnagpal commented 6 years ago

@sagarpreet-chadha @jywarren How do we fetch all the location objects from the database?

jywarren commented 6 years ago

ah, sorry, that issue seems so long ago! Thanks!

On Fri, Jun 29, 2018 at 12:54 PM Mridul Nagpal notifications@github.com wrote:

@sagarpreet-chadha https://github.com/sagarpreet-chadha @jywarren https://github.com/jywarren How do we fetch all the location objects from the database?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/leaflet-blurred-location-display/issues/9#issuecomment-401412577, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ6QvYz1UFjpopRL_NqVqdUgbiXypks5uBlucgaJpZM4SayPc .

stefannibrasil commented 6 years ago

Hi, everyone, for now, we are not working on that, but we definitely can in the next weeks! What I am almost finishing is this #2790

sagarpreet-chadha commented 6 years ago

Thats great @stefannibrasil !

@mridulnagpal ...we use API 😄 . See the list of API's here : https://github.com/publiclab/plots2/blob/master/app/api/srch/search.rb and this for example : https://github.com/publiclab/plots2/blob/37372c2e3840eb7d63a2861e18bb57196de5add8/app/views/map/_leaflet.html.erb#L14

Hope that helps !

jywarren commented 6 years ago

For starters i think you can use a set of example data that's in the same format, so look at functions here:

https://publiclab.org/api/docs/ and https://github.com/publiclab/plots2/blob/master/doc/API.md

and maybe use https://publiclab.org/api/srch/taglocations?srchString=41,-89

You can have this be an example file you save statically in the library, in fact, in the example.

jywarren commented 6 years ago

But we might also think about the API providing a standard GeoJSON output?

mridulnagpal commented 6 years ago

@jywarren Working on a prototype, will push a demo soon!!

mridulnagpal commented 6 years ago

Hey @jywarren I tried $.getJSON("https://publiclab.org/api/srch/taglocations?srchString=41,-89", function(data) { console.log(data); }); And am getting the error:

Failed to load https://publiclab.org/api/srch/taglocations?srchString=41,-89: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

jywarren commented 6 years ago

Ah, I think we need a cors permission on publiclab.org - @icarito would you be able to help? Thanks!

On Thu, Jul 12, 2018, 11:04 AM Mridul Nagpal notifications@github.com wrote:

Hey @jywarren https://github.com/jywarren I tried $.getJSON("https://publiclab.org/api/srch/taglocations?srchString=41,-89", function(data) { console.log(data); }); And am getting the error:

Failed to load https://publiclab.org/api/srch/taglocations?srchString=41,-89: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/leaflet-blurred-location-display/issues/9#issuecomment-404543790, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJyJqLBdUaQIAzUNmcdmmzi8ewLVkks5uF2VggaJpZM4SayPc .

icarito commented 6 years ago

Sure, will do!

On 12/07/18 11:13, Jeffrey Warren wrote:

Ah, I think we need a cors permission on publiclab.org - @icarito would you be able to help? Thanks!

On Thu, Jul 12, 2018, 11:04 AM Mridul Nagpal notifications@github.com wrote:

Hey @jywarren https://github.com/jywarren I tried

$.getJSON("https://publiclab.org/api/srch/taglocations?srchString=41,-89", function(data) { console.log(data); }); And am getting the error:

Failed to load https://publiclab.org/api/srch/taglocations?srchString=41,-89: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub

https://github.com/publiclab/leaflet-blurred-location-display/issues/9#issuecomment-404543790, or mute the thread

https://github.com/notifications/unsubscribe-auth/AABfJyJqLBdUaQIAzUNmcdmmzi8ewLVkks5uF2VggaJpZM4SayPc .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/leaflet-blurred-location-display/issues/9#issuecomment-404567151, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMMS3liqR7Ra2gA0qJFyudHj-cvHrENks5uF3XGgaJpZM4SayPc.

icarito commented 6 years ago

Hi! Please test! I think widely enabling Access-Control-Allow-Origin could facilitate some spoofing so I've enabled it only for the /api/ routes! I hope that is enough? Let me know if you want other routes with that header added!

mridulnagpal commented 6 years ago

@icarito Yeah thanks man it works!!

mridulnagpal commented 6 years ago

@jywarren Here is the prototype blurreddisplay

stefannibrasil commented 6 years ago

hey, everyone, @milaaraujo and I would be happy to help with anything. Do you still need some method from the API that we can help with? Cheers!

mridulnagpal commented 6 years ago

@stefannibrasil The CORS error was resolved and now I can use the API, thanks :)

jywarren commented 6 years ago

Ooh, this is really nice @mridulnagpal -- do you have a PR open for this? Do you think you could configure your fork's gh-pages branch and push this code there so we can try it out at https://mridulnagpal.github.io/leaflet-blurred-location-display/examples/ ?

Great work!

mridulnagpal commented 5 years ago

@jywarren Done, you can test it here!! https://mridulnagpal.github.io/leaflet-blurred-location-display/examples/

jywarren commented 5 years ago

Cool! I'm not seeing any markers, though. And there does seem to be an old error, maybe we're not using the latest version here?

image

But good start, exciting!

mridulnagpal commented 5 years ago

@jywarren I am directly installing from npm, should we update the version there?

mridulnagpal commented 5 years ago

@jywarren #10 will be done once the API is updated, what should we add till then?

jywarren commented 5 years ago

OK i'm publishing a new version on npm! But, where do I look for the markers? Should I be seeing them when I start it up?

jywarren commented 5 years ago

published!

jywarren commented 5 years ago

Can we put a list of sample locations in the example/index.html file to show how this works, in the demo? And is this code now in the master branch? Can you push it into the publiclab/gh-pages branch too so we can show the demo there? Thanks!

jywarren commented 5 years ago

And with demo locations in the example file, we can move forward on #10, too, right? Thanks, Mridul!!!

mridulnagpal commented 5 years ago

@jywarren Do you mean move to a location by default where there are already tags?

jywarren commented 5 years ago

No, i meant actually that we hard code in some locations, so, you could inline in the index.html, have a static array of locations that help do demonstrate the usage of this library without relying on a remote resource. What do you think?

mridulnagpal commented 5 years ago

Got it, working on it!!

mridulnagpal commented 5 years ago

@jywarren What's next?

mridulnagpal commented 5 years ago

@jywarren Should we move to something new as well?

jywarren commented 5 years ago

Yes, as soon as you're getting #13 working, i think you should think about how each grid square could be shaded darker based on how many blurred locations are within it -- want to think a little bit about how that could work? Would a function go through the visible grid squares and count, then establish a scale from "none" to "many" and shade accordingly, each time setZoom is run?