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

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

Closed
mridulnagpal opened this issue Mar 3, 2018 · 44 comments

Comments

@mridulnagpal
Copy link
Member

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

@jywarren
Copy link
Member

jywarren commented Mar 9, 2018 via email

@mridulnagpal
Copy link
Member Author

@jywarren Can you give an example?

@jywarren
Copy link
Member

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
Copy link
Member Author

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

@mridulnagpal
Copy link
Member Author

@jywarren Can you give a code example?

@jywarren
Copy link
Member

^ 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: publiclab/plots2#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
Copy link
Collaborator

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 :

  • /people map with SEARCH + Recent Contributors ,
  • /profile with FULL Screen And Near-by Users maybe ,
  • a new-layer map with all options to choose different layer ( #2486 ) ,
  • etc..

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
Copy link
Member Author

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

@mridulnagpal
Copy link
Member Author

@jywarren Any views?

@jywarren
Copy link
Member

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

@jywarren
Copy link
Member

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
Copy link
Member

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
Copy link
Collaborator

Hi @jywarren ...dynamic fetching of new data on zooming or panning is still not solved in this issue publiclab/plots2#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
Copy link
Collaborator

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

@mridulnagpal
Copy link
Member Author

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

@jywarren
Copy link
Member

jywarren commented Jun 29, 2018 via email

@stefannibrasil
Copy link

stefannibrasil commented Jun 29, 2018

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
Copy link
Collaborator

@jywarren
Copy link
Member

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
Copy link
Member

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

@mridulnagpal
Copy link
Member Author

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

@mridulnagpal
Copy link
Member Author

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
Copy link
Member

jywarren commented Jul 12, 2018 via email

@icarito
Copy link
Member

icarito commented Jul 12, 2018 via email

@icarito
Copy link
Member

icarito commented Jul 13, 2018

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
Copy link
Member Author

@icarito Yeah thanks man it works!!

@mridulnagpal
Copy link
Member Author

@jywarren Here is the prototype
blurreddisplay

@stefannibrasil
Copy link

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
Copy link
Member Author

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

@jywarren
Copy link
Member

jywarren commented Jul 18, 2018

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
Copy link
Member Author

@jywarren
Copy link
Member

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
Copy link
Member Author

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

@mridulnagpal
Copy link
Member Author

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

@jywarren
Copy link
Member

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
Copy link
Member

published!

@jywarren
Copy link
Member

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
Copy link
Member

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

@mridulnagpal
Copy link
Member Author

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

@jywarren
Copy link
Member

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
Copy link
Member Author

Got it, working on it!!

@mridulnagpal
Copy link
Member Author

@jywarren What's next?

@mridulnagpal
Copy link
Member Author

@jywarren Should we move to something new as well?

@jywarren
Copy link
Member

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?

@jywarren jywarren changed the title Adding features to leaflet blurred location display Adding features to leaflet blurred location display (needs breaking up into separate issues) Nov 14, 2018
@jywarren jywarren closed this as completed Apr 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants