Locations Plugin


(Angus McLeod) #163

Hey, yeah I did consider it briefly a month or so ago. What’s the use case you have in mind?


(Joe Buhlig) #164

I have my personal instance for notes. I like to collect a database of restaurants with geotags so I can look at a map and see the ones I like. I often snap a pic of the menu while I’m there and upload it right away for future reference. Geotagging that spot would allow me to save the extra steps of looking up and entering the restaurants address.


(Angus McLeod) #165

Interesting! What do you reckon @ckshen? Would your community use something like that?


#166

Probably limited for us. I think most of our users prefer to report their meals after the fact versus while they are eating.

Thanks.


(Ivan Rapekas) #167

Hi, ~recently I posted a desirable feature in Discourse there. Interesting to know, how that feature might cover your needs, guys!

Thanks.


(François Douville) #168

Is it possible to add a link to the site map to the hamburger menu? Same as events plugin.


Learn how to build Discourse plugins by helping me
(Angus McLeod) #169

Yup, we can add that.

To do list:

  1. Add a link to the Site-level map in the hamburger menu

  2. Improve map filters (see e.g.).

  3. Add auto-detection of user’s location.


#170

Angus, please also leave an option for users to select their location manually. This way they can choose an approximate location that at least identifies the district they live in (and City/Country), without having to give up too much privacy :).


(Mittineague) #171

If not manual entry, might an option to reduce the scale cause enough blurring?

eg. instead of 43.12345, 43.12000


(Greg) #172

Is anyone else having issues with the OpenCage geocoder? I’ve signed up for the free tier, but it’s throwing errors in Discourse saying the API key is wrong (it’s not, I checked). Here’s the logs (cut’n’paste from the Discourse console isn’t great, sorry):

Summary

Message (4 copies reported)

GeocoderError (Geocoding provider api key invalid. Please contact your site administrator.) /var/www/discourse/plugins/discourse-locations/lib/geocode.rb:100:in `rescue in perform’

Backtrace

/var/www/discourse/plugins/discourse-locations/lib/geocode.rb:100:in rescue in perform' /var/www/discourse/plugins/discourse-locations/lib/geocode.rb:86:inperform’ /var/www/discourse/plugins/discourse-locations/lib/geocode.rb:75:in search' /var/www/discourse/plugins/discourse-locations/controllers/geocode.rb:8:insearch’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_controller/metal/basic_implicit_render.rb:4:in send_action' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/abstract_controller/base.rb:186:inprocess_action’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_controller/metal/rendering.rb:30:in process_action' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/abstract_controller/callbacks.rb:20:inblock in process_action’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:131:in run_callbacks' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/abstract_controller/callbacks.rb:19:inprocess_action’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_controller/metal/rescue.rb:20:in process_action' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_controller/metal/instrumentation.rb:32:inblock in process_action’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166:in block in instrument' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21:ininstrument’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166:in instrument' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_controller/metal/instrumentation.rb:30:inprocess_action’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_controller/metal/params_wrapper.rb:252:in process_action' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/railties/controller_runtime.rb:22:inprocess_action’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/abstract_controller/base.rb:124:in process' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionview-5.1.4/lib/action_view/rendering.rb:30:inprocess’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-mini-profiler-1.0.0/lib/mini_profiler/profiling_methods.rb:104:in block in profile_method' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_controller/metal.rb:189:indispatch’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_controller/metal.rb:253:in dispatch' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/routing/route_set.rb:49:indispatch’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/routing/route_set.rb:31:in serve' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/journey/router.rb:50:inblock in serve’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/journey/router.rb:33:in each' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/journey/router.rb:33:inserve’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/routing/route_set.rb:834:in call' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/engine.rb:522:incall’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/railtie.rb:185:in public_send' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/railtie.rb:185:inmethod_missing’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/routing/mapper.rb:17:in block in &lt;class:Constraints&gt;' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/routing/mapper.rb:46:inserve’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/journey/router.rb:50:in block in serve' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/journey/router.rb:33:ineach’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/journey/router.rb:33:in serve' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/routing/route_set.rb:834:incall’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-protection-2.0.1/lib/rack/protection/frame_options.rb:31:in call' /var/www/discourse/lib/middleware/omniauth_bypass_middleware.rb:24:incall’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/conditional_get.rb:25:in call' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/head.rb:12:incall’ /var/www/discourse/lib/middleware/anonymous_cache.rb:200:in call' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/session/abstract/id.rb:232:incontext’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/session/abstract/id.rb:226:in call' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/cookies.rb:613:incall’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/callbacks.rb:26:in block in call' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:97:inrun_callbacks’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/callbacks.rb:24:in call' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/debug_exceptions.rb:59:incall’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/show_exceptions.rb:31:in call' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/logster-1.2.9/lib/logster/middleware/reporter.rb:31:incall’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/rack/logger.rb:36:in call_app' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/rack/logger.rb:26:incall’ /var/www/discourse/config/initializers/100-quiet_logger.rb:16:in call' /var/www/discourse/config/initializers/100-silence_logger.rb:29:incall’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/remote_ip.rb:79:in call' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/request_id.rb:25:incall’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/method_override.rb:22:in call' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/executor.rb:12:incall’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/sendfile.rb:111:in call' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-mini-profiler-1.0.0/lib/mini_profiler/profiler.rb:285:incall’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/message_bus-2.1.4/lib/message_bus/rack/middleware.rb:63:in call' /var/www/discourse/lib/middleware/request_tracker.rb:186:incall’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/engine.rb:522:in call' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/railtie.rb:185:inpublic_send’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/railtie.rb:185:in method_missing' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/urlmap.rb:68:inblock in call’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/urlmap.rb:53:in each' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/urlmap.rb:53:incall’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/unicorn-5.4.0/lib/unicorn/http_server.rb:606:in process_client' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/unicorn-5.4.0/lib/unicorn/http_server.rb:701:inworker_loop’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/unicorn-5.4.0/lib/unicorn/http_server.rb:549:in spawn_missing_workers' /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/unicorn-5.4.0/lib/unicorn/http_server.rb:142:instart’ /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/unicorn-5.4.0/bin/unicorn:126:in &lt;top (required)&gt;' /var/www/discourse/vendor/bundle/ruby/2.4.0/bin/unicorn:23:inload’ /var/www/discourse/vendor/bundle/ruby/2.4.0/bin/unicorn:23:in `<main>’

Env (trimmed)

|REQUEST_URI|[/location/search?request%5Bquery%5D=10, /location/search?request%5Bquery%5D=Hochschule%20Bonn-Rhein-Sieg, /location/search?request%5Bquery%5D=ams, /location/search?request%5Bquery%5D=yay]|
|REQUEST_METHOD|GET|
|HTTP_USER_AGENT|Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0|
|HTTP_ACCEPT|/|
||params null|

Anything else I can provide? We’re not over our usage, as far as I can tell (and presumably that would return a different error). I’ve reverted to Nominatim for now, as our usage isn’t high (yet), so it’s not urgent.

BTW, thanks for this & the events plugin, you do great work!


#173

Can this plugin be used to display all forum members locations on the map?
Would it require extra programing?


(Angus McLeod) #174

Yes, this will always be the main option. Auto-location detection will be an optional feature.

I just gave it a whirl and it’s working ok for me: Location with OpenCage - Locations - Angus’ Sandbox

When is the error being thrown? In Site Settings or in the Add Location modal? If it’s in Site Settings make sure you’re adding the key first then switching to Open Cage for your provider (it won’t work if you switch provider first).

@Sudaraka and I have been working on that exact feature for the past couple of months :slight_smile: He’ll be launching it here very soon.


(Greg) #175

It’s in the Add Location modal - I just got a red bar between the “Add a Location” and “Address” text, but no actual error appears. It was working to begin with, and seems to be working now, so perhaps it’s was a few hours of weirdness on the OpenCage end… I’ll monitor it, thanks!

This may be a big ask but is there a way to preview what the map location will be? Right now I’m having to either (a) repeatedly save/edit a post until I figure out a location that works, or (b) refine my search on the OpenCage demo site. Previewing the map in the modal would be amazing


(François Douville) #176

In location input, there is postalcode but it is only possible to write numbers. Here in Quebec, Canada, we have letters, for example : J3K 8G4

Thanks


(Jacob ) #177

This plugin is great, thank you! I was wondering if it is possible to change the location input from an address to a map where the user can click on the location(Think rural natural disasters, where there is no street address.)


#178

2 minor formatting suggestions:

  • Make the Location and Date/time button the same height.
  • Keep them on the same row.


(Angus McLeod) #179

Good. Let me know if anything changes.

Yeah. I actually originally built it that way, but changed it back for some reason (I forget now). It may be time to re-add a preview map.

Yeah good point. I’ve removed that restriction.

You know it’s also possible to use a free text input right? (disable the location input fields enabled site setting). Example with a number / letter postcode:

Screenshot%20at%20May%2012%2020-35-33

Great idea, will add it to the list. There is a manual way of adding locations with no geocoded address, as this plugin does support direct entry of latitude and longitude:

  1. via the api (example curl cmd with lat / lon); and

  2. via the input fields: enable location input fields enabled site setting and add coordinates to the location input fields site setting.

Both should be true in the current version.

What version are you running and do you have any custom styles that could be affecting the buttons? (I see there’s an added border-radius to your buttons).

Here’s what you see when you create a new topic in the events category on my sandbox:

Screenshot%20at%20May%2012%2020-44-16


To do list:

  1. Add a link to the Site-level map in the hamburger menu <-- currently being worked on via Mentoring program.

  2. Improve map filters (see e.g.).

  3. Add auto-detection of user’s location.

  4. Look closely at error handling for missing locations or api errors (there should be no blank error messages - see).

  5. Add preview of location on map in Add Location modal.

  6. Allow user to select topic location by clicking on map.


(Jacob ) #180

Just to expand on my idea from earlier. I think it would be great if the user could input an address, like the default settings, and have the map appear essentially confirming the location. At this point the user could click on the map to confirm a more accurate location.


(Sudaraka Jayathilaka) #181

Hello all,
@Angus and I have been working on a new feature for Locations plugin which permits adding user locations in a separate map for the last couple of months. So far, the new feature is working very well on the sandboxes we used and merged to the Discourse Locations Plugin master branch.

It’s live on Angus’s Sandbox

Here is a step by step guide to use the plugin,

  1. First enable the setting in the plugin settings section in admin settings which allows users location functionality

  2. Then add your location in the user profile preference page

  1. And save the changes by clicking the button in the latter part of the same page

  1. Now you can view your location and the locations of other users in /u/user-map like following

  • You can toggle users list and the map using nav buttons on top of the map
    image

  • You can visit the profiles of users in the map by clicking on the map pin
    image

@8BIT, @hellekin, @merefield hope you would be interested in this new feature :slight_smile:


Visual map of users
#182

Fantastic. Will take a look!