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

Implement changes to fractracker mobile layer #330

Merged
merged 4 commits into from
Jan 8, 2020

Conversation

crisner
Copy link
Contributor

@crisner crisner commented Jan 7, 2020

Fixes #87 (<=== Add issue number here)

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updation
  • ask @publiclab/reviewers for help, in a comment below

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

@crisner
Copy link
Contributor Author

crisner commented Jan 7, 2020

Work done:

  • Implemented GeoJson layer that fetches data on map's moveend event

Thinks to do:

  • Check and refactor popup code

127 0 0 1_5500_example_index html (5)

@crisner
Copy link
Contributor Author

crisner commented Jan 7, 2020

@jywarren, I have set the maximum number of results per page which is 250. I was thinking users would zoom in to get detailed information which would trigger a request resulting in loading markers they may have missed before. But some views may still have more than 250 results. How do you think we should implement this? Should I loop through the pages to load all the markers for the map view the user is on? The current layer setup won't allow the user to access the layer for zoom levels that are less than 5.

var polygon = left + ' ' + top + ',' + right + ' ' + top + ',' + right + ' ' + bottom + ',' + left + ' ' + bottom + ',' + left + ' ' + top;

var $ = window.jQuery;
var fractrackerMobile_url = 'https://cors-anywhere.herokuapp.com/https://api.fractracker.org/v1/data/report?page=1&results_per_page=250&q={"filters":[{"name":"geometry","op":"intersects","val":"SRID=4326;POLYGON((' + polygon +'))"}],"order_by":[{"field":"report_date","direction":"desc"},{"field":"id","direction":"desc"}]}';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey,
What is this url cors-anywhere.herokuapp.com ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to remove the cors policy issue. Jeff had suggested using it in the issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it doesn't fetch the results if this is not prepended. But I am planning to look into it more tomorrow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows us to fetch it despite CORS restrictions. We've confirmed this is OK with the FracTracker team. Thanks!

@sagarpreet-chadha
Copy link
Collaborator

Hey @crisner ,

In the URL you have used: page=1&results_per_page=250
So this will fetch same 250 results everytime, right?

@crisner
Copy link
Contributor Author

crisner commented Jan 7, 2020

In the URL you have used: page=1&results_per_page=250
So this will fetch same 250 results everytime, right?

It depends on your map view. But it would fetch the same results for the same map view. To put it simply it depends on the map's current bounds.

Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just assume people will keep zooming in to find more. 250 is a lot! It sounds good for now! Thanks!!!

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

I think this looks good to go! Shall we merge it?

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

I need to go over the popup information to make sure I haven't missed anything. It will be ready today (Jan 8). Thanks! :)

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

Also, noting it here to remind myself to update the leafletEnvironmentalLayers.js file with the change.

@crisner crisner changed the title [WIP] Implement changes to fractracker mobile layer Implement changes to fractracker mobile layer Jan 8, 2020
@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

Changes done:

  • Refactored popup code to handle undefined and null from data properties
  • Changed layer name to match with the one listed in README.md
  • Updated AllLayers.js file to reflect the changes
  • Added promise to ajax request

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

I've also added a simple test to check if the layer gets added to the map. I tried to check for markers but because of the delay in response, the data doesn't become available when the test runs. There should be a better way to check this. I'll work on this later this week or when we are adding missing tests. For now, this PR is ready. Thanks!

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

This is awesome! Thanks so much. Shall we bump the version number in package.json and also get the latest gh-pages branch pushed up so the main demo is live?

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

Sure. But if I'm not wrong, we had already bumped it once from 2.0.6 to 2.1.6 and hadn't published it. Do we bump it again?

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

well, in theory only the commits up until the version change in package.json should be included, i think... i guess it's kind of an ambiguity though. I think I can just publish this as 2.1.6 since we ought to have published it as 2.1.0 before anyways. Sound good?

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

Yes, sounds good. :)

@jywarren jywarren merged commit f10a792 into publiclab:master Jan 8, 2020
@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

publishing!!

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

Sorry, do we need to do any grunt build on this before publishing? if so, i can just push out a 2.1.7?

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

Yes, I guess. We have git ignored the build file. So I think we have to run grunt build before publishing.

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

if so, i can just push out a 2.1.7

Sounds good.

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

ok, no prob - 2.1.7 coming up. I can release it fast enough that it'll supercede 2.1.6

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

done!

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

now doing gh-pages

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

It's live! Let's test it out, then let's watch at plots2 for dependabot to bump the LEL version in a PR there... i can give dependabot a nudge from its website console too...

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

This is so great. I'm finding some things I'd like to make follow-ups for; is there a place to put these for now?

  • More layers (like FTM) in menu? - so before we publish, the current demo shows only a few of the layers... this wouldn't get copied into plots2 yet without more integration, right? I just don't want to publish on plots2 before all the existing layers are included. Thanks!
  • Permalinks for popups? Like, if you open a popup maybe we can have a # button that links you back to this place AND it opens that same popup... this could be tough but useful... i don't see how we have a unique id here, but could we do it based on the layer and... timestamp? lat/lon? This might need some brainstorming.
  • Less urgent: ways to show when a layer /will be active/ for the given bounding box - do we highlight it, do we have a tooltip to explain, do we show a bounding box when people hover on the layer?

This looks great!

https://publiclab.github.io/leaflet-environmental-layers/example/#lat=40.0333&lon=-75.1557&zoom=10&layers=Standard,fracTrackerMobile,skytruth,toxicReleaseLayer,mapknitter,Power

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

image

So nice!

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

I am getting a Uncaught ReferenceError: Spinner is not defined when I try to access the above links.

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

Hmm. Would spinner be an npm req? I included all new npm modules, i think!

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

Yes. Looks like it is not included in the node modules.

GET https://publiclab.github.io/leaflet-environmental-layers/node_modules/leaflet-spin/example/spin/dist/spin.min.js net::ERR_ABORTED 404

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

I'll hold on bumping dependabot until we're sure here, so give me a heads up! Thanks for everything, this is so exciting :-)

Oh, one more idea! (sorry to dump them here, let's find a place to put them, and we don't have to act on all of these, they're just inspirations while I'm using it) -
- So: We could have a url hash flag to have the menu expanded?

OK i'll try to include it in gh-pages and republish that.

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

Looks like blurred location and blurredlocationDisplay are also missing.

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

Hm. That spin file is not present here: https://github.com/publiclab/leaflet-environmental-layers/tree/gh-pages/node_modules/leaflet-spin/example/spin

is it supposed to be part of the npm package as pulled in? Is it being gitignored?

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

Oh, one more idea! (sorry to dump them here, let's find a place to put them, and we don't have to act on all of these, they're just inspirations while I'm using it)

I have a few ideas myself. 😅 I was planning to note them all in a planning issue to discuss it first thing tomorrow morning. Maybe you could open a planning issue and put them there? and then I could add on to it?

We could have a url hash flag to have the menu expanded?

Awesome idea.

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

Hm. That spin file is not present here: https://github.com/publiclab/leaflet-environmental-layers/tree/gh-pages/node_modules/leaflet-spin/example/spin

is it supposed to be part of the npm package as pulled in? Is it being gitignored?

Let me check

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

OK awesome -- would you mind opening this list issue? That'd be super - and isn't our meeting Friday morning, not tomorrow?

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

Yes. Friday morning, your time.

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

would you mind opening this list issue?

Yes. Shall do it.

Btw, the dist file exists in the node modules in the local repo and node modules are git ignored in other branches anyway.

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

Sorry in the local machine. The file exists in my local copy.

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

And the file exists in the gh-pages branch of my copy https://github.com/crisner/leaflet-environmental-layers/tree/gh-pages/node_modules/leaflet-spin/example/spin/dist

The branch is not updated with the latest commits though. May be running npm install again would fix it?

@crisner
Copy link
Contributor Author

crisner commented Jan 8, 2020

I have opened an issue, #334 as a place to add and discuss new ideas. Shall edit the post with a few of my ideas and description tomorrow.

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

You're right, I had missed some modules! Pushing them now.

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

And regarding layers, it now appears to load all layers! Maybe it was the missing modules that stopped it.

@crisner
Copy link
Contributor Author

crisner commented Jan 9, 2020

I guess this resolves this comment? I'd like to note that unearthing layer is not included. Shall we include that too in the demo?

@jywarren
Copy link
Member

jywarren commented Jan 9, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add FracTracker mobile app data layer
3 participants