# Improve our global map by better integration with the forum

**URL:** <https://tzm.one/t/improve-our-global-map-by-better-integration-with-the-forum/22125>\
**Category:** Projects\
**Tags:** it-team\
**Created:** [July 29, 2022, 10:21am UTC](https://tzm.one/t/improve-our-global-map-by-better-integration-with-the-forum/22125 "2022-07-29T10:21:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kees](https://tzm.one/user_avatar/tzm.one/kees/32/8442_2.png) [@Kees](https://tzm.one/u/Kees)\
**Post date:** [July 29, 2022, 10:21am UTC](https://tzm.one/t/improve-our-global-map-by-better-integration-with-the-forum/22125/1 "2022-07-29T10:21:50Z")

</div>

The Fairphone forum uses the map below.

> **[Fairphone Community Map](https://forum.fairphone.com/t/fairphone-community-map/26553?u=uppercase)**
>
> Continuing the discussion from Do you know an open source alternative to embedded maps? I present to you: The Fairphone Community Map! 🗺 🎉 @Roboe and I have been working on it for over 7 month and we are happy that we are finally able to show it...

This is integrated with their forum and we can do the same thing of course. This can be done by creating the email aliases and connect them to our [groups](https://tzm.one/groups). Then we need to link our [events](https://tzm.one/calendar) plugin with this applet and then we have a better [global map](https://tzm.one/map) of our chapters and events. But also the ability to easily contact chapters.

Their software is #open-source, but time is limited on my side. I can have a look next year. But our movement would work best if we spread the load and delegate tasks, when possible and needed. It doesn’t seem to be a whole lot of work though. But it does require some dedication to do it right 🤓 It may be just changing the data sources and verify if they work. But this needs to be checked, and I don’t even have that time to spare at the moment.

Just a nudge to our [@it-team](https://tzm.one/groups/it-team), if anyone is looking for #Activism > Projects😉

> **[GitHub - WeAreFairphone/fprsmap: This is a Leaflet map of the local Fairphoners...](https://github.com/WeAreFairphone/fprsmap)**
>
> This is a Leaflet map of the local Fairphoners communities

---

<div class="post-metadata">

**Author:** ![Kees](https://tzm.one/user_avatar/tzm.one/kees/32/8442_2.png) [@Kees](https://tzm.one/u/Kees)\
**Post date:** [July 30, 2022, 11:40am UTC](https://tzm.one/t/improve-our-global-map-by-better-integration-with-the-forum/22125/2 "2022-07-30T11:40:33Z")

</div>



---

<div class="post-metadata">

**Author:** ![Kees](https://tzm.one/user_avatar/tzm.one/kees/32/8442_2.png) [@Kees](https://tzm.one/u/Kees)\
**Post date:** [July 30, 2022, 12:03pm UTC](https://tzm.one/t/improve-our-global-map-by-better-integration-with-the-forum/22125/3 "2022-07-30T12:03:19Z")

</div>

I dived a bit in the code, it works pretty simple and the Fairphone community made it very readable and usable. I already got it working on my laptop with the Fairphone data sources

I want to host the map as localhost on the server and then make it available to the forum via the local Docker network for security reasons. I don’t want to run this code publicly, it’s not that actively maintained for that. This can be done soon. I just have to create the data sources and see if our event plugin is compatible. So far it doesn’t look like that and Fairphone uses a semi-official event plugin for that. I can live without events on the map for now and figure that out later.

---

<div class="post-metadata">

**Author:** ![Kees](https://tzm.one/user_avatar/tzm.one/kees/32/8442_2.png) [@Kees](https://tzm.one/u/Kees)\
**Post date:** [July 30, 2022, 1:31pm UTC](https://tzm.one/t/improve-our-global-map-by-better-integration-with-the-forum/22125/4 "2022-07-30T13:31:18Z")

</div>

After some more careful examination, I think the Fairphone setup is actually not _that_ well integrated with the forum as it can be. It can be made much easier.

Fairphone at the moment uses [this yaml formatted topic](https://forum.fairphone.com/raw/48676/1) to populate the map. Where the location name is used to compile an email address for the group. The coordinates are manually inserted and they manually maintain a list of users. Furthermore, they use a boolean to switch a listing on or off or indicate if it’s active or not. This yaml file is then converted to json and then looped through it to compile the listing for the map as well.

We could simplify this. We could simply use the [json layout of our groups](https://tzm.one/g.json). If a group is not active, it’s not listed. So when the parser loops through it, it drops from the map/list. We can show the amount of users, since the `user_count` is listed there. And if a group is listed on the forum, but has no members, then it should not be on the map with the email address. Because then no one will receive those emails.

The `name` of the group is e.g. `chapter_netherlands`, we could do a substring replacement for the `_` with a `-` and that then becomes our email address. We could also filter based on the name, if it starts with `chapter`, process it. Then we can split the name, e.g. `chapter_netherlands` based on the `_` and then use a public API to get some coordinates for `netherlands` and put the `title` of the group, e.g. “Chapter Netherlands” on the map with those coordinates.

The only “downside” is that we won’t have flags this way. Maybe there is a public API that can give us the correct emoji for a flag based on `netherlands` or `amsterdam`, like 🇳🇱. But I’ll drop that feature. The map shows where it is, flags may be nice for a future iteration of this, if needed at all.

* * *

Edit, yes, I think I’ll create my own version of this which will be even simpler and easier to maintain than the Fairphone one.

Another edit: I’ll make a theme component out of this, for Discourse. That way I inherent the security maintenance from the Discourse devs and benefit from their security layers and libraries. But first a simple proof of concept will be made.

* * *

So since the plan changed, a new checklist of todo’s.

Get data source to extract all necessary data (chapter name, email address, members and if the chapter is considered active) ([Discourse API Docs](https://docs.discourse.org/#tag/Groups/operation/listGroups)) - [https://tzm.one/g.json?filter=chapter](https://tzm.one/g.json?filter=chapter)  
 A way to query cities/countries and get coordinates in return to be used to draw a point on the map ([https://nominatim.openstreetmap.org/search?q=amsterdam&format=json](https://nominatim.openstreetmap.org/search?q=amsterdam&format=json))  
 Or create plugin to add custom field for groups, to include coordinates  
 Loop through the data  
 Draw all the chapters on the map  
 Create all the mail aliases for the groups  
 Allow the domain where the javascript runs be allowed in the CORS security settings  
 Cherry pick some parts from the Fairphone map listing to show and sort chapters with member count, group URL and group email address  
 Create standalone proof of concept

* * *

Optionally:  
 Expand the proof of concept into a Discourse theme component ([Developing Discourse Themes & Theme Components - Developer Guides - Discourse Meta](https://meta.discourse.org/t/developer-s-guide-to-discourse-themes/93648))

---

<div class="post-metadata">

**Author:** ![Kees](https://tzm.one/user_avatar/tzm.one/kees/32/8442_2.png) [@Kees](https://tzm.one/u/Kees)\
**Post date:** [August 7, 2022, 5:15pm UTC](https://tzm.one/t/improve-our-global-map-by-better-integration-with-the-forum/22125/5 "2022-08-07T17:15:16Z")

</div>

Small update in the form of a screenshot 🎉 I haven’t worked with JavaScript in the past. But It starts to grow on me. Just a few more steps and I’ll be able to draw things on the map dynamically. I’ll also create a Discourse plugin to allow custom fields for groups, to override the coordinates, when needed. And then Fairphone may use this different approach as well of course. It’s easier to use existing data rather than manually maintain a separate list.

 ![Screenshot from 2022-08-07 19-12-49](https://tzm.one/uploads/default/original/2X/5/5ba37068055b492534a9b82856a216bfbce46d4c.jpeg)

---

<div class="post-metadata">

**Author:** ![Kees](https://tzm.one/user_avatar/tzm.one/kees/32/8442_2.png) [@Kees](https://tzm.one/u/Kees)\
**Post date:** [September 1, 2022, 12:53pm UTC](https://tzm.one/t/improve-our-global-map-by-better-integration-with-the-forum/22125/6 "2022-09-01T12:53:12Z")

</div>

Created a custom plugin for Discourse (the forum) to add more options for group admins. This includes coordinates and an option to publish the email address on the map as well. This information will be available via the public Discourse API and will then be used to draw the chapters on the map.

 ![Screenshot 2022-09-01 at 21-01-26 Profile - Manage - chapter_netherlands - TZM Community Forum](https://tzm.one/uploads/default/original/2X/8/87ae153ebe1eb653329e36e64fb509948ae66fef.png)

And it works! 🎉 I will cleanup some code and finish the final bits and pieces, but then the new map can go online for public testing. If all goes smooth, we should have an improved map within a week or so.

https://www.youtube.com/embed/UO5SrCGw9wY?feature=oembed&wmode=opaque

* * *

To finalize the map:  
 Brand the map for TZM (replace Fairphone icons/text)  
 Create a JavaScript substring for the chapter description to filter out/fix the relative links in the hashtags (e.g. #nl)  
 Don’t draw circles for chapters, create a bigger marker which is easier to see  
 Contact the Fairphone devs and ask them how and if they want credits for their work we’re using on our map  
 Harden the webserver/code which will host the map  
 Create logic to only show the chapter map toggle in groups which includes the name “chapter”

Once the above is finished, I’ll have a look at the map + chapter listing with automatic metadata about the chapters.

* * *

Changed the markers, much better visible now.

 ![Screenshot from 2022-09-03 09-17-58](https://tzm.one/uploads/default/original/2X/6/6a3d24cd99f98219336a8c0e1df778c297690fcc.png)

---

<div class="post-metadata">

**Author:** ![Kees](https://tzm.one/user_avatar/tzm.one/kees/32/8442_2.png) [@Kees](https://tzm.one/u/Kees)\
**Post date:** [September 5, 2022, 1:43pm UTC](https://tzm.one/t/improve-our-global-map-by-better-integration-with-the-forum/22125/7 "2022-09-05T13:43:09Z")

</div>

The chapter map listing is now also done! There is still some hardening needed and minor tweaks. But it’s already pretty mature 🎉

 ![Screenshot 2022-09-06 at 23-42-41 Just a test for embedding to see if CSP conflicts BANGLADESH - Staff - TZM Community Forum](https://tzm.one/uploads/default/original/2X/c/cf45f1870c9bea1d17f5c4d84315609f4c2963ea.png)

---

<div class="post-metadata">

**Author:** ![Kees](https://tzm.one/user_avatar/tzm.one/kees/32/8442_2.png) [@Kees](https://tzm.one/u/Kees)\
**Post date:** [September 11, 2022, 12:33pm UTC](https://tzm.one/t/improve-our-global-map-by-better-integration-with-the-forum/22125/8 "2022-09-11T12:33:00Z")

</div>

I consider this project closed. I will improve it over time with webpack, better caching, npm package management and merge everything into one page (it now loads the map as a separate page into the chapters overview).

In case people want to help/contribute:

> **[GitHub - kees-closed/TZM-Chapters-Map: A global chapters overview of The Zeitgeist...](https://github.com/kees-closed/TZM-Chapters-Map)**
>
> A global chapters overview of The Zeitgeist Movement

---

<div class="post-metadata">

**Author:** ![Kees](https://tzm.one/user_avatar/tzm.one/kees/32/8442_2.png) [@Kees](https://tzm.one/u/Kees)\
**Post date:** [September 14, 2022, 5:01pm UTC](https://tzm.one/t/improve-our-global-map-by-better-integration-with-the-forum/22125/9 "2022-09-14T17:01:20Z")

</div>

~~Bug found~~ , will fix it in time, but can’t prioritize. In a nutshell, the JSON call only shows 35 results, we now have more than 35 chapters on the forum. So not all chapters are shown. I’ll need to make the retrieval a bit smarter. For now it will simply not collect all chapters. There is no quick fix. I need to make something in JavaScript or Python that retrieves the next page of results of the total amount of entries have not been collected yet.

> **[How to increase max search results for groups (in JSON)](https://meta.discourse.org/t/how-to-increase-max-search-results-for-groups-in-json/239009?u=aqual1te)**
>
> I have created a map for my groups called chapters: These values are queried from https://forum.tzm.community/g.json?filter=chapter, but it seems that the max search results have been hit. How and where I can increase this? This is important...

Update: Bug is solved! 🎉

Also removed the flags, people probably have strong opinions about that.

---

<div class="post-metadata">

**Author:** ![Kees](https://tzm.one/user_avatar/tzm.one/kees/32/8442_2.png) [@Kees](https://tzm.one/u/Kees)\
**Post date:** [September 28, 2022, 5:02pm UTC](https://tzm.one/t/improve-our-global-map-by-better-integration-with-the-forum/22125/10 "2022-09-28T17:02:10Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
