Locations Plugin

(Ryan Erwin) #200

@Francois_Douville We’ve completed implementation of the site wide “Map” link from the hamburger menu under @angus’s mentor program (Learn how to build Discourse plugins by helping me).

New “/map” related admin settings


Map in the top menu

Map in the hamburger menu


Site wide map in action

Activate it…

This is live in the current github code… so just ./launcher rebuild... or git pull or whatever your environment requires to get the latest plugin code.


OK, I’ve started to explore this plug-in in my dev server but have come across an issue:

  • http://my-dev-ip/admin/users/list/active has 3 users including my admin account BUT
  • http://my-dev-ip/u/user-map shows no users despite Map Location being non-blank for the admin account

I checked the code in users_map.rb and ran the following in Data Explorer, comes back non-blank and shows my admin account:

SELECT user_id FROM user_custom_fields WHERE name = 'geo_location'

Any ideas why /u/user-map is not showing anything?

Edit, yeah, I can see the data is coming into the browser when debugging in the map widget … but it’s not showing … it’s something else … any ideas @Sudaraka?

(Craig Davison) #202

How can we display user location on profile? I’ve noticed @angus has ‘New York’ displayed on his profile on the test forum but I wonder how this can be enabled.

(Sudaraka Jayathilaka) #203

Hello @merefield,
First thank you for using the feature :blush: . Can you please check whether the users you are referring to are shown in the user list which can be seen in http://my-dev-ip/u


Thanks for responding. No results either. No results were found.

Yet as I said http://my-dev-ip/admin/users/list/active has three users … (but only one ‘human’).

NB only other plug-in installed is discourse-plugin-outlet-locations

(Sudaraka Jayathilaka) #205

The issue is with how Discourse updates the users list as per my suspicion. It is explained here.

Are you running sidekiq for the forum? If you do, the users will appear in the users list after some time. When you can see the users on /u list, you will be able to see the user locations on the map as well :slight_smile:. Please let me know if the issue isn’t resolved



Though I can see the data in the Ember record whilst debugging, but nevertheless you are correct that sidekiq is not running. From the dashboard:


Any way to cajole it into running the required job from command line without having to have sidekiq fully up?

(Sudaraka Jayathilaka) #207

What is the deployment method you used for deploying the forum? you may have to revisit the tutorial you followed for that and look for how to run sidekiq. If you are on local you can simply use
bundle exec sidekiq in console.
I think this works for other deployments as well. But I have to check :grin:


The normal cloud dev install.

Here’s a couple of interesting things from debug with widget/map. Should showAvatar be ‘undefined’? Note the data from the location is in the browser for the user:

If I trace that back … the args are undefined in map-component?:

so looks like showAvatar being undefined is the issue? Any idea why it might be?

(server would not allow me to successfully run sidekiq:

Fatal process OOM in heap setup)


I really like the idea of the plugin, but I ran into some issues while testing it. And I had a few requests.


  • Could you add State as an Input Field?
  • Add a cancel button so if you are editing an address that has already been entered, you can exit without making changes.
  • Add an option for Default Country.


  • If a geocode isn’t selected, the address is lost when saving the post. The images below show what I am seeing.


  • If a geocode isn’t selected, I am not able to click done if a search has been performed or I edit a post. The error is below.

_ember_jquery-27e777857b8c0730dacfe09cb11711365d21a5db4f9ee0b85d494e4259cf6cda.js:29446 TypeError: Cannot read property ‘lat’ of undefined
at submit (_plugin-third-party-25726b7617b6488f7c8b2b1a512009ba4e0567322c14839e6c70ca43bba1af2a.js:11392)
at send (_ember_jquery-27e777857b8c0730dacfe09cb11711365d21a5db4f9ee0b85d494e4259cf6cda.js:43589)
at s.triggerAction (_ember_jquery-27e777857b8c0730dacfe09cb11711365d21a5db4f9ee0b85d494e4259cf6cda.js:47291)
at sendAction (_ember_jquery-27e777857b8c0730dacfe09cb11711365d21a5db4f9ee0b85d494e4259cf6cda.js:50748)
at s.click (_application-52dc2f1eb1666e764d21013234d1859d2cf67d8180f80e26e6ff85cdefc3230f.js:40582)
at s.trigger (_ember_jquery-27e777857b8c0730dacfe09cb11711365d21a5db4f9ee0b85d494e4259cf6cda.js:52345)
at s.n [as trigger] (_ember_jquery-27e777857b8c0730dacfe09cb11711365d21a5db4f9ee0b85d494e4259cf6cda.js:50483)
at p.run (_ember_jquery-27e777857b8c0730dacfe09cb11711365d21a5db4f9ee0b85d494e4259cf6cda.js:12915)
at p.join (_ember_jquery-27e777857b8c0730dacfe09cb11711365d21a5db4f9ee0b85d494e4259cf6cda.js:12952)
at Function.u.join (_ember_jquery-27e777857b8c0730dacfe09cb11711365d21a5db4f9ee0b85d494e4259cf6cda.js:34030)

(Angus McLeod) #210

@merefield Sidekiq has to be running for the user map feature to work. Did you manage to get it running?

I’ve added ‘state’ as a possible input field: Add state && move country_codes to site serializer · angusmcleod/discourse-locations@da3bbf8 · GitHub

Do you mean a button that performs the same function as the ‘x’ in the top corner of the add location modal?

I’ve added this too: Add default country setting · angusmcleod/discourse-locations@478a980 · GitHub

I’m not sure what you mean by “If a geocode isn’t selected”


Thank you for those changes.

I don’t see a ‘x’ at the top of modal. While testing this, I noticed different behavior from the Events plugin modal as well. Clear will close the location modal, while clear does not close the events modal. I do not see an ‘x’ on the events modal either. I am on a version from a week ago for both.

If an address is added, but I don’t click Find Address, the address isn’t displayed.

This is what I see after closing the modal and before saving the post.

This is what I see after saving the post. And if I don’t have a name entered, then it only shows the location icon and no text.

If I go to edit the address, I am unable to click done in the modal again since I didn’t Find Address. Here is the error from the console. This error only goes away by clicking Find Address (which isn’t always desired) or refreshing the page.

(Jay Dawg) #212

@angus May I say what a brilliant plugin, there so much scope for this, I have one issue not sure if it has been addressed or if I am doing something wrong.

When I put the full address in,it finds the address which is fine but no icon displays on the map.

Also in some posts I only want to just put the city and country will it still show the post’s city?

Finally I get this error

DevTools failed to parse SourceMap: https://content.quantcount.com/adchoices/v2/css/300x250.css.map

Could this be stopping the map icon

Any help would be appreciated


(Jay Dawg) #213

Ok I managed to get it working, I did not realised you had to click on the geocoded address result and then press ‘Done’ But you have to fill out all fields before the find address button is activated.

Would it be possible to geocode the full address or just the entered city on it’s own… Some of my users only need to enter the city of the post and some only need to enter the full address

I removed the address and postcode from admin and it then it does allow the ‘City’ to be geocoded but then obviously I dont have the option to enter the full address.

Is there a way to override this issue please


@Sudaraka, @angus thanks guys, it was an issue with sidekiq … I got sidekiq running and the user icons now show in dev … great!

(Angus McLeod) #215

Both modals definitely have an X and have for some time. See e.g: Events - Angus' Sandbox


Do you have any custom CSS that could be hiding it? Are there any exceptions in the browser console?

Ah, right yup. There was an issue for non-geocoded locations. This should fix it. Please update and try again.

Do you want geocoded locations though? You can enforce geocoded locations by setting location geocoding to ‘required’


Also not sure if this applies, but if you want to have an single input address entry, i.e.:


Deselect this:


@menzer The single input address entry may be what suits your needs too. Give it a try and let me know.

(Jay Dawg) #216

You are the boss!! How simple was that,thank you!

Possible idea: I’d like the option to show latest posts only on the map. ie:l show only posts added in x number of days? we we can select the number of days


It was another plugin causing the X to not appear. The Content Locker plugin was causing the issue, which was recently marked as broken anyway. So I have removed it.

I like the idea of optional geocoding, but turning it off may be best for now for me. Most of the locations I tried were getting a general location on the road and not the actual address. That would probably be fixed by changing to a different service for that though.

Thank you for changes and fixes.

(Ben Harper) #218


This is a fantastic plugin, dreaming of the ways I hope to make use of it!

We are bringing several thousand users into discourse (from vanilla) and using WP as the SSO provider, and so the users will not be manually creating a profile on discourse.
We have addresses for most users in WP, however I am not sure simply auto mapping users is a good idea, in fact I know its not;)

So my question is how would you go about prompting users during their first login to add their locations to their profile so that they are displayed on the users map. No one will know to do so unless prompted, and no one will follow an instruction email to login and complete the task, it would need to be a really quick addition while you were entering the site, to set and move on or otherwise I feel it will be left undone.

I would really like the majority of users to be shown on the map, maybe at a suburb level and not with full address resolution. Its for a hi-tech geeky group of garden shed machinists, there are not allot of them around and so we want to help them find each other both on and offline - without it getting creepy.

We plan to have some localised topics including a Market for swapping /selling parts as well as professional services area and a real life social area where we will encourage people to find members of the community to go and have a bbq, talk shop or help each other with a project, as in away from the internet. I know that sounds strange. Of course for this functionality we can turn on location required on these categories.

The map will feature heavily in making this possible! Would not otherwise work, and so … very exciting.
Leading to the next question, not location plugin specific but . can you associate a user with a topic, without them having to add a post. For example how would I get people to opt in to the social category and be shown on the map in that category. Is it the case that they would have to make a post and I would have the location required setting on that category or are other options available?

And lastly, it would be pretty awesome if the maps allowed for custom icons, like a $ sign for users on the market, a sausage for those interested in getting together.

Thanks again Angus for the awesome plugin!

(Angus McLeod) #219

Sounds like an interesting community!

You can use my Custom Wizard Plugin.

When you have both the Locations Plugin and the Custom Wizard Plugin installed, create a wizard with ‘After Signup’ enabled.

In one of the steps, add a field with the type ‘location’. Then add an “Update Profile” action and map the location field to the user custom field 'geo_location. This is what it should look like

If you sign up for an account on my sandbox, you’ll see an example.

The Users Map is site wide. There’s no users map for each category at the moment. The category maps are for locations associated with topics.

Custom icons are possible, but I won’t be getting as granular as having different custom icons for different types of locations for some time. You may want to consider hiring a dev to make a customisation of the plugin for that (and maybe category-specific user maps).