-
-
Notifications
You must be signed in to change notification settings - Fork 730
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
Add support for using Open Street Map on the Map and Group pages. #5398
Conversation
Thanks so much! Leaflet looks like exactly what we needed. 😄 I think we could probably bring back some of the lost search functionality with a bit of tweaking, possibly via the We'll probably need to make some configuration changes in the Exciting PR! It might be a while before it can be merged though 👍 |
You are making many people happy with this PR @cillian :-) I think that instead of making this PR ready to replace google maps, I'd just adapt the config in this PR to make OSM the default maps solution in OFN. I'd say we should ship this (default OSM + google maps as the extra solution). From there we can gradually improve this OSM solution and make it replace google maps for all instances. I'll do a detailed code review when we agree on what's the general approach to this PR. Anyway, this PR made my day! |
It is true we will need to add some routes and update some details for some farms. But we already do hit for Google and it is super easy on OSM. For the CSA network in France, the farmer can use this tool : https://nominatim.openstreetmap.org/ Also I understand that in countries like Australia where OSM is really poor in data, the need for Google maps is still there. I think the most important thing is to keep the choice. Whether or not one should be default and not the other I have no opinion. However if OSM is default, we should make sure that the deployment does not change this for all current instance. Could endup with a lot of problems. |
👍 ..sounds good, I'll leave it with you all for now then. If it needs any changes please let me know. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I am just approving this PR as is.
If we ship this nothing will change for existing instances and other instances can switch to this solution and try OSM. We can then improve this until it becomes the default.
I'm just having a little play with this now. It's working really well. I think I'll try to make some improvements to it at some point, but for now I think I agree we can just merge it and iterate. We should add a notice in the Wiki though: the current default provider has usage restrictions and should only only be used for a bit of testing. It shouldn't be used long-term or on a larger production server. We should also have a look at the alternate free and paid providers that can be used, and maybe recommend one. |
@@ -0,0 +1,15 @@ | |||
module PreferenceSections | |||
class MapSection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: the preferences are hard to find in the config section. We could move them to a new map settings page.
markers.push(marker) | ||
|
||
displaySearchField = () -> | ||
new Autocomplete('#open-street-map--search', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: we can use a different search box using Geocoding (like the /shops search) and get the old search behavior back. If we do that we can probably ditch the Autocomplete javascript dependency. See geocoding
gem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @cillian! ❤️
Hi @cillian - thank you for this PR! One issue though: I see codeclimate has several types of issues to resolve - perhaps these should be addressed before testing? |
@@ -0,0 +1,19 @@ | |||
# frozen_string_literal: true | |||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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 ignore the other 2 warnings 👍
Good point @filipefurtad0 👍
0779607
to
6c0ec4f
Compare
Hi @filipefurtad0, @luisramos0 No problem, that's done now. Let me know if it needs more changes. |
Nice, thanks @cillian Ready for testing 👍 |
The map is displayed using https://leafletjs.com/ To enable Open Street Map go to the Admin -> Configuration -> Content section and click 'Open Street Map Enabled'. The 'Open Street Map Provider Name' setting can be used to configure different tile providers thanks to the Leaflet-providers extension (https://github.com/leaflet-extras/leaflet-providers) Some tile providers require an API key, this can provided in JSON format e.g. '{ apiKey: 123 }' in the 'Open Street Map Provider Options' setting. Each tile provider has their own usage policy so this should be checked before enabling Open Street Map. The search field for the Open Street Map works differently than searching on Google Maps. It matches producers by their name or address because it was easier to implement instead of matching place names all over the world.
6c0ec4f
to
8e57f9d
Compare
I've rebased this to resolve some merge conflicts and added a slight adjustment that was needed after the rebase. |
Hi @cillian , Thanks for tackling this! The PR definitively removes dependency from google maps, as shown on the console (second pic, below) but somehow the map is not being displayed. After this PR, and enabling Open Street Map in the Content section (superadmin): This might be due to staging issues; maps never really worked well on fr-staging - right @RachL? Perhaps a good idea to test this on a different server. More on this soon @cillian - thanks again 👍 |
@filipefurtad0 yes gmaps is not working in FR. But I thought it was specific to gmaps. Worth checking on another staging. |
Alright, Before this PR (nothing to show on this map, the staging-fr related issue): After this PR - in staging-es: Group maps work as well. Awesome! |
Can anyone tell me what would happen to Aus enterprise addresses that aren't on osm if we switched this? Would they just disappear from the map? Would we need to ask all existing enterprises to check and create themselves, do it ourselves, or is there an automated way to do it? |
@kirstenalarsen We're adding an optional alternative, not really changing anything yet. It needs some more work, but the idea is that instances will be able to use it without any of the problems you've listed. |
thanks @Matt-Yorkley I understand that :) I was just wondering if instances like Aus did want to switch to it, if we did switch to it, what would happen? |
or in saying 'it needs more work' you're imagining that there would be solutions to those problems that would mean that we could switch? |
yes! this issue will help to understand that Kirsten: #5542 |
That's correct any enterprise with the |
Actually the geocoding we do when an enterprise is saved is handled by a separate gem, which is not connected to the maps javascript. So new enterprises would still appear on the map. 👍 I've already written up a bit of a roadmap detailing the bits of work would need to be done to solve the outstanding issues. |
wait, but if geocoding still works if you switch to osm maps, then the only problem with using osm is the search. I wonder if that doesn't make some instances want to switch immediately. |
It's close, but not close enough... |
So - I activated this on OFN_CAN - and there are a few issues you can see: first - on the main page, the map opens to Japan - is there a way to have it default open to the instance? Second - the map formats like a banner image, versus a large square for SOME but not all of our groups pages. See these links: https://openfoodnetwork.ca/map, See this group map: https://openfoodnetwork.ca/groups/https-www-stcatharines-ca-en-experiencein-stcatharinesfarmersmarket-asp#/map versus this group map: https://openfoodnetwork.ca/groups/guelph-farmers-market#/map Any idea why the difference in the group maps? And - now that I see this, I probably want to go back to google maps for OFN-CAN until we fix this more - can I just back out? If I just uncheck open street map in configuration - will it go back? (maybe I shouldn't have experimented ) |
@tschumilas yes please switch back to google maps. There is quite a few work to do before we can use this on live instance: #5542 |
OK - will do, sorry I jumped the gun here. I'm guessing I just de-select the open street map and presto - I'll be back.? |
What? Why?
For #5078
This lets people use Open Street map.
The map is displayed using https://leafletjs.com/
The search field for the Open Street Map works differently than searching on Google Maps. It matches producers by their name or address instead of matching place names all over the world because this way easier to implement I found.
To enable Open Street Map go to the Admin -> Configuration -> Content section and click 'Open Street Map Enabled'.
The Open Street Map Provider Name setting can be used to configure different tile providers thanks to the Leaflet-providers extension (https://github.com/leaflet-extras/leaflet-providers)
Some tile providers require an API key, this can provided in JSON format e.g.
{ apiKey: 123 }
in the Open Street Map Provider Options setting.Each tile provider has their own usage policy so this should be checked before enabling Open Street Map.
What should we test?
Note I haven't got automated tests working locally yet but I will try check they are passing later.
Release notes
Adds support for displaying maps usings Open Street Map.
Changelog Category: Added
Discourse thread
https://community.openfoodnetwork.org/t/i-need-help-on-configuring-ofn-without-external-data-collection/1889
Documentation updates