Locations Plugin

I’ve just merged many early mornings and late nights of work to get this show back on the road.

It is very different in implementation from the old plugin so please bear with there are probably lots of issues, I’ve barely tested it in Production:

  • As part of the changes I’ve deprecated the use of widgets in favour of Glimmer implementation (widgets will eventually be on their way out). This was quite a journey, I can tell you, as the original widget code is very esoteric indeed. This should set us in good stead for a good while.
  • There’s a new search system which is a little OTT (be good to add group capability at some point? if someone wants to sponsor that get in touch! )
  • It no longer supports Layouts, but Layouts is currently :skull: so that’s moot - I’ll look to add back Layouts support when Layouts returns from the :skull:
  • I’ve cut some corners to get here so quickly - I’ve not added any additional FE tests … may get time to add ones for the maps over time.

NB I’ve added a compatibility file so Stable should still use the old code whilst we iron out the bugs in this new approach over time …

Known Issues:

  • expand doesn’t work nicely atm.
  • Name search on the User map has issues.
  • Layouts is not yet supported (but that’s currently :skull: )


Il have just update and …the map live :heart_eyes: :heart_eyes: :heart_eyes:

Merci beaucoup :revolving_hearts:


that’s great @Stephane_Roy … but I think also screaming out for a dark mode?

I haven’t had time to look at that yet as an auto integration into the plugin, but there was this CSS I shared a while back you can add as a Theme Component:

:root {
  --map-tiles-filter: brightness(0.6) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);

.locations-map {
  .leaflet-tile-pane  {
    filter:var(--map-tiles-filter, none);
  .leaflet-marker-shadow {
    display: none;

that I believe still works …

might be a little easier on the eyes? :sunglasses:


Still works (“normal” and dark): Sidemount-Forum

Btw, I just upgraded and also the plugin works again (but I skipped the non-working time period :wink:).


I just wanted to bring this up again as a feature request.

We are just having this in our community when planning an event. People now use Google Maps to see how far away the suggested event location is.

Also it is useful when checking out how far away the other user is. (We run a scuba diving forum and people look for diving buddies in our forum.)


@Roi, you might be interested in this:

With this release we introduce (experimental) natural language search for user locations with Discourse Chatbot :robot: , so you can ask it things like:

  • “List the five nearest users to my location” … (if you’ve registered a location) … or even
  • “List all users within 500km of my location.”
  • “List the users within 200km of Berlin.”

It doesn’t yet support Topic Locations … but that’s 2/3rds done and in the pipeline …

There’s a data migration in this release, so please let me know if anyone has any issues and I will try to help.


I know this is still a work-in-progress so you may already know about these…

  1. Sometimes when I open the User Map I get a blank map, i.e. countries map displayed but no users on it. If I refresh the page then the mapped users re-appear. I haven’t found a guaranteed way to replicate this, but I see the blank map at least 50% of the times I open the user map. The blank map only seems to appear on the user map. I’ve not see it on the topic map, at least not so far.

  2. There’s a blank white box to the left of the name/username/etc radio button fields, e.g.


1 Like
  1. Yeah, the solution is not perfect. It’s not my focus at present. PR accepted.

  2. is entirely intentional: it’s a search box.

1 Like

Ahhh! So it is.

I just found something else. My topic map doesn’t have many entries on it, but in the US I have 3 clustered on the east coast and two clustered on the west coast. If I click the east coast cluster it zooms in to display the three individual topic locations. If I click on any of those locations rather than opening the associated topic it zooms in to show the two west coast locations. This is repeatable - try it on my site Weather-Watch Forum


Very curious indeed! Strangely they are working fine on my data. I also note on your map, there is an error when hovering over a cluster.

Leaflet version is seriously dated … might be an issue …

1 Like

OK I’ve pushed the version of Leaflet and its popular marker cluster plugin to latest, see if that helps:

We might as well break it properly with latest code :sweat_smile:

(there is no point in even discussing such issues if we are running an old library, who knows what they’ve fixed!).


Thanks for the quick update. On an initial test it’s behaving better now. I’ve not got the weird east to west coast jump on the couple of tests i’ve tried. I’ll do some more testing tomorrow.


Yeah, I can see. Great! Thanks for rechecking promptly.


After more testing today it looks like the last update has fixed the blank map on first opening and also the weird east to west coast jump from clustered locations :grinning:


Thank you for pointing this out to me, and sorry, that I was not around here for some days to comment.

That really sounds promising. :slight_smile: But at the moment, we do not have the AI Chatbot active in our forum. I am still struggling with guessing how much this would cost us to get an API key from OpenAI. As we run our community in a non-profit way and do not charge, we hardly get the server and domain costs out of the few donations and other stuff like this. So that is an important topic for us. :wink:

The link to the answer in the post with the example calculations does not work anymore. Can you tell me where to find it? :slight_smile:

And besides the AI Chatbot integration: Are you thinking about putting a distance information into the plugin as well? So simply showing the distance from the current logged in user to an event or to another user - if both sides have set an location? That was the simple way it was handled in the location plugin for phpBB we used before.

The cost post was deleted I’m afraid as the Topic was getting stupidly long. I’ll remove that from the OP. (Done)

I suggest trying it out : permission staff only initially.

No, I don’t plan to make it available in the Locations plugin without the Chatbot.

For all you subversive subfolder users out there, @renato has kindly PR’d to make sure the markers work in such a configuration:

Thanks very much @renato! :pray:


One quick question:
How do I update this plugin? run ./reset-all-repos seems risky.
Goal is to only update this plugin, and not lose the data of the 180 projects already entered.

1 Like

That’s not really a plugin specific question, but you will need to be running tests-passed and update to latest to get all the new stuff working.

It’s always risky :sweat_smile: , unless you want to run a Stable install? (in which case this update is not yet relevant).

The online upgrade (from /admin/upgrade) might work for you, or as usual, rebuild with ./launcher rebuild app - assuming you are running a standard install?

I cannot vouch for the rest of your plugins maintenance levels, but good luck! :sweat_smile:

1 Like

Encountered the same problem.

I tried the method listed here

But not working.
Ubuntu system, reboot not working,
./launcher restart app, ./launcher start app not working.

Error Message when running ./launcher rebuild app

111:M 12 Dec 2023 12:11:02.199 * DB saved on disk
111:M 12 Dec 2023 12:11:02.200 # Redis is now ready to exit, bye bye...

Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 3553 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.

Thank you for @itsbhanusharma

It says caused by earlier error, I list them here

I, [2023-12-13T00:50:13.222274 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundl                e exec rake db:migrate'
2023-12-13 00:50:18.347 UTC [3597] discourse@discourse ERROR:  invalid input syntax for type double precision: ""

2023-12-13 00:50:18.347 UTC [3597] discourse@discourse STATEMENT:  INSERT INTO locations_topic                 (topic_id, latitude, longitude, name, street, district, city, state, postalcode, country, count                rycode, international_code, locationtype, boundingbox, updated_at, created_at) (
        FROM topic_custom_fields tc
        WHERE tc.name = 'location'
        AND tc.value NOT IN ('"{}"', '{}', '')
        AND tc.value::json->'geo_location'->>'lat' IS NOT NULL
        AND tc.value::json->'geo_location'->>'lon' IS NOT NULL

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled: (StandardError)

ERROR:  invalid input syntax for type double precision: ""
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rack-mini-profiler-3.3.0/lib/patches/db/pg.rb: 110:in `exec'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rack-mini-profiler-3.3.0/lib/patches/db/pg.rb: 110:in `async_exec'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/mini_sql-1.5.0/lib/mini_sql/postgres/connection.rb:202:in `run'

Caused by:
PG::InvalidTextRepresentation: ERROR:  invalid input syntax for type double precision: "" (PG:: InvalidTextRepresentation)
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rack-mini-profiler-3.3.0/lib/patches/db/pg.rb: 110:in `exec'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rack-mini-profiler-3.3.0/lib/patches/db/pg.rb:  110:in `async_exec'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/mini_sql-1.5.0/lib/mini_sql/postgres/connection.rb:202:in `run'

and the docker ps message

/var/discourse# docker ps
CONTAINER ID   IMAGE                 COMMAND        CREATED             STATUS         PORTS                                                                      NAMES
d3c8e85149a8   local_discourse/app   "/sbin/boot"   About an hour ago   Up 6 minutes>80/tcp, :::80->80/tcp,>443/tcp, :::443->443/tcp   app