gbif / hosted-portals

Support material for establishing the GBIF Hosted Portals
Apache License 2.0
10 stars 6 forks source link

New filter "within radius of xxx meters" #269

Open jholetschek opened 1 year ago

jholetschek commented 1 year ago

The target group of the LAND hosted portals are also laymen, which might be interested in the direct surrounding. So a filter "all occurrences within xxx meters around my current location" would be nice.

Related to https://github.com/gbif/hp-land/issues/10 (show current location in map)

MortenHofft commented 12 months ago

We have such a filter in the API. But so far i've been avoiding it as I'm not sure how to implement it in a user friendly way. Not exactly sure technically either. I'm not sure how this work in different projections either. There is also something odd about drawing different geometries in on the map that behave differently (AND vs OR)

The simplest solution I can think of just now is to not draw the geometry in the map view. But only have it as a filter with coordinates and radius. possibly a map (in the filter popup) in mercator. I think Tissot circles are circles everywhere in mercator? And then restrict range to mercator as well.+-85 lat

MortenHofft commented 11 months ago

I wonder if that audience is better served a different way altogether. Using that filter as an invisible background filter. But with a different UI more targeted the casual user.

The occurrence search as it is is more of a nerdy tool. Not really well optimised for the one time random citizen user, despite my best efforts to make it simple. Just the fact that search is using scientific names is enough to make it confusing. And all the darwin core terms when viewing individual records do not help either.

Perhaps the use case you describe is better served by something like ALAs explore my area tool https://biocache.ala.org.au/explore/your-area I hear it is by far the most visited part of their site. Perhaps it is time that we implement something similar now that we start to have these portals.

jholetschek commented 11 months ago

Yes, I agree. The filters are a bit nerdy, and the "explore my area" is something else. Maybe this could be another tab - with the map centered on the current location and already zoom in? This wouldn't require an additional filter at all.

MortenHofft commented 11 months ago

You could kind of hack that, by having an explore my area link on the homepage, that goes to the mapview and sets to mapcenter to the users location.

I've added an example here https://github.com/gbif/hp-land/commit/c61f06c4405716dc8b1b74872e508d2d9ed24a73 That code was entirely generated by chatgpt btw. Which is why there is a weird json stringify of a float in there. I'll remove that

it could probably benefit from a loader. Getting the users location can be a slow process

UPDATE: I've added a loader

MortenHofft commented 11 months ago

btw - I've made it so that it should attach to any link tags with the class gbifExploreMyAreaLink

jholetschek commented 11 months ago

Wow... thanks Morten! That's scary. Which question did you ask ChatGPT?

MortenHofft commented 11 months ago

I ended with a dialog of 3 questions, but compiled to one question it would be

You are a programming assistent an expert in javascript. Could you please provide me with a function for an a tag click event, that when called will fetch the users location, store it in session storage and afterwards redirect to the href of the link tag?

The click event should attach to all links with class: exploreMyArea

And could you add a class "is-loading" to the link while fetching location please

the session storage items should be mapLat, mapLng and mapZoom=12