EnviroMonitor / EnviroMonitorFrontend

Frontend for EnviroMonitor
http://air-monitor.org
GNU General Public License v3.0
4 stars 3 forks source link

Adding map API #5

Closed ajakubo1 closed 7 years ago

ajakubo1 commented 7 years ago

Any suggestions on map API?

Google maps seem to be a sensible choice, as those are free for non-profit applications:

https://developers.google.com/maps/pricing-and-plans/#details

Do you know of any other sensible map alternative?

zen commented 7 years ago

OpenStreetMap - but I'm not sure if they have API.

I'm in general OK with Google, but it would be great to make it pluggable.

ajakubo1 commented 7 years ago

You mean in case we want to swap it?

Yeah, no problem, I'll try to abstract it :).

zen commented 7 years ago

Yes. Google changed their different policies many times, I would not rely on this for 100%

ajakubo1 commented 7 years ago

Hmm, this one looks quite interesting as well: http://leafletjs.com/

And they did a stable release 1.0.0 a couple of months ago.

zen commented 7 years ago

Yeah, that looks pretty cool and it's really lightweight. I would give it a try

lechup commented 7 years ago

It's open source so I think we should go leaflet + OSM.

PS: I hope we do not need to host OSM map service? ;)

lechup commented 7 years ago

Oh, and I assigned @ajakubo1 to this issue. Any objections? :)

ajakubo1 commented 7 years ago

Nope, none at all. I'll read up and create a prototype :).

lechup commented 7 years ago

@ajakubo1 do we want to host tile service connected to Leaflet?

I've checked pricing for Mapbox: https://www.mapbox.com/pricing/

And it looks much more expensive than Google's Map API (checking free app/web): https://developers.google.com/maps/pricing-and-plans/#details

We have 30*25000 monthly limit on Google, 50000 monthly limit on mapbox ...

Maybe we should stick to Google Maps?

ajakubo1 commented 7 years ago

Hi, @lechup - for now I'm using OpenMaps from what I know. I have some problems with the build configuration though (not because of OpenMaps, integration with webpack+react is little bit weird to me) :/. I should have something usable by the end of the week.

lechup commented 7 years ago

Ok, cool. Do You mean OSM? Like here? https://switch2osm.org/using-tiles/getting-started-with-leaflet/

What limits does it have? Is it usable? I mean it is not sluggish and loads quite fast?

ajakubo1 commented 7 years ago

@lechup yeah, that's the one.

I can see that they suggest using your own data server:

https://operations.osmfoundation.org/policies/api/

And is it sluggish? Well, to tell you the truth I don't feel it's sluggish. The whole thing takes a second to load :).

I think I've handled most problems I had. Things left to do:

I'll do some of those today I think :).

lechup commented 7 years ago

@ajakubo1 ok, so for first version we just use their tiles service right? Then we could write to API holders whether we should get our solution or not.

I could set up OSM tile service, but still we would need to proxy it through our backend and require token (and timestamp?) to actually do not let to abuse it... http://stackoverflow.com/a/31640941/479931

I do not have any idea what kind of HW do we need for our usage but still it is doable - but increases running costs a bit...

ajakubo1 commented 7 years ago

@lechup Yeah, I think we can use theirs for now, but I would have the OSM tile service in the back of my head. To tell you the truth that's something which @zen should consider more (as he would deploy it all, I think ;)).

Anyway, if you have a couple of seconds you can checkout this branch: https://github.com/EnviroMonitor/EnviroMonitorFrontend/tree/adding_map

I have a feeling this pull request might be quite big, but I want to add everything which we might need in futther development.

Anyway, if I add the fetch library, and input some test data, I'll open the pull request for it.

zen commented 7 years ago

Folks, I can set up tile server if that's needed. Just let me know if we run into any perf problems with current setup. Still, that's fine for our global instance, but what about users deploying their own backend/frontend? It can be a showstopper for them :(

ajakubo1 commented 7 years ago

For internal usage (I mean one person wants to set it up and has like 2 sensors or something), it should be fine using the global OSM. But - if our project would be used for country-wide-monitoring or city-wide-monitoring, then I guess we would have to suggest setting up their own OSM tile service for performance.

I'm not sure if we should block the page somehow for bigger traffic? Nah, that would be weird, it's open-source anyway :). So anyone can hack it in their own branch.

BTW - I'll check what is the current page size with map fully loaded.

lechup commented 7 years ago

@zen @ajakubo1 Shouldn't we go into way we are hosting all instances? I mean we could support local Smog Alarm Groups:

I think it will be much more user friendly than "set up Your own soft infrastructure". What do You think guys?

zen commented 7 years ago

I'm all for hosting it for others, and maybe you are right that if someone chooses to host it himself, it's out of our scope. So, I would assume that we host central instance and allow users to set up their own frontend to use our data. They need to post some sensor data though, to get access to resources.

ajakubo1 commented 7 years ago

Yeah, I'm OK with setting up our own server and allowing users to use it, if they are contributing to the overall data scope. That's quite user-friendly, and everyone is getting something out of it :).

Btw. I've just checked and the whole thing weights about 1.1 MB. And half of that is our scripts (well, mostly vendor scripts really). On my modem it takes about 2s to load right now (last time I've checked I've had better connection).

lechup commented 7 years ago

@ajakubo1 1.1 MB - I think we should go with some kind of loader for slower connections. React apps just need some more data at the beginning but later it just works.

lechup commented 7 years ago

Done in #15