# Locations Plugin 🌍

**URL:** https://meta.discourse.org/t/locations-plugin/69742
**Category:** Plugin
**Tags:** paid-support
**Created:** [September 10, 2017, 10:36am UTC](https://meta.discourse.org/t/locations-plugin/69742 "2017-09-10T10:36:41Z")
**Posts on this page:** 20
**Page:** 4

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [June 10, 2020, 12:52pm UTC](https://meta.discourse.org/t/locations-plugin/69742/545 "2020-06-10T12:52:24Z")

</div>

Thanks @merefield that’s exactly what we had tried 🙂

Alas, it still pauses to load the User List page first, _then_ it redirects to the map.

I was hoping just the map might be available on `/map` or something 🙂

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [June 10, 2020, 12:53pm UTC](https://meta.discourse.org/t/locations-plugin/69742/546 "2020-06-10T12:53:58Z")

</div>

Gotcha.

But it’s a red herring.

The vanilla User List is cached so it loads in a split second. The issue is the length of time it takes to load the model for the map, which in your case is ~400 users in one go … so yeah, the User List rendering is wasting 0.1% of the processing time, but the real problem is the latter part. There may be no quick solution to that.

I know this partly because I just deployed to a site which hasn’t used this facility previously. The map data loads so quickly that User List is never visible (despite it loading first). The rub? Only 2 users have so far pinned their location … the User Map doesn’t scale well with its current architecture.

---

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [June 10, 2020, 1:05pm UTC](https://meta.discourse.org/t/locations-plugin/69742/547 "2020-06-10T13:05:47Z")

</div>

Interesting insight, thanks.

We only have around 12% of our community members on the map at the moment and we were recently discussing a drive to get more members on there.

Would I be right in thinking that as our community continues to grow, we can expect the map loading to get slower and slower?

---

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [June 10, 2020, 1:06pm UTC](https://meta.discourse.org/t/locations-plugin/69742/548 "2020-06-10T13:06:36Z")

</div>

I’m guessing too that it has to load the user list first?

Knowing nothing about the code, is it possible to just have the map on it’s own somewhere? 🤔 🤷‍♂️

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [June 10, 2020, 1:23pm UTC](https://meta.discourse.org/t/locations-plugin/69742/549 "2020-06-10T13:23:18Z")

</div>

Like I said, that’s irrelevant. The user list is cached and very short.

---

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [June 10, 2020, 2:27pm UTC](https://meta.discourse.org/t/locations-plugin/69742/550 "2020-06-10T14:27:14Z")

</div>

> [@merefield](#):
>
> The issue is the length of time it takes to load the model for the map

Does the Locations plugin use its own model for this or an existing core one? I’m wondering where the bottleneck in selecting just 400 rows of user information from the database is?

Sorry for all the questions @merefield just trying to better understand how it works under the hood 🙂

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [June 10, 2020, 2:36pm UTC](https://meta.discourse.org/t/locations-plugin/69742/551 "2020-06-10T14:36:43Z")

</div>

No problem Richie. We override the DirectoryItemsController to pull back more people in one go than would normally occur when the data is paged for the normal table. The model is no different.

This really needs a root and branch replacement with a much more complex data streaming system that is aware of the viewport size and location. That’s quite a lot of work I suspect. Not least because that will no longer be able to leverage as much of the code that comes with Discourse, it’s a completely different use case. Quite an interesting piece of work though!

The fact that you are seeing this delay _every_ _single_ _time_ suggests its not caching, and that could be something we might be able to fix without massive changes.

---

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [June 10, 2020, 4:38pm UTC](https://meta.discourse.org/t/locations-plugin/69742/552 "2020-06-10T16:38:07Z")

</div>

> [@merefield](#):
>
> The fact that you are seeing this delay _every_ _single_ _time_ suggests its not caching

I haven’t missed or changed a simple Discourse setting have I?? 🤦‍♂️

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [June 10, 2020, 4:39pm UTC](https://meta.discourse.org/t/locations-plugin/69742/553 "2020-06-10T16:39:21Z")

</div>

No, it’s not your issue, except that you may have outgrown the current capabilities of the plugin 🙂

When I get chance, I’ll look into what it might take to cache the results so you will only experience that issue once per session. That’s the low hanging fruit.

The bigger tree surgery however …

---

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [June 10, 2020, 7:05pm UTC](https://meta.discourse.org/t/locations-plugin/69742/554 "2020-06-10T19:05:42Z")

</div>

> [@merefield](#):
>
> you may have outgrown the current capabilities of the plugin

😢

> [@merefield](#):
>
> When I get chance, I’ll look into what it might take to cache the results so you will only experience that issue once per session

Thanks @merefield but hang fire on that one. I have no evidence either way but my suspicion would strongly be that people only ever look at the map once per session anyway 🤔

---

<div class="post-metadata">

### Author: ![k4rtik](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/k4rtik/32/119508_2.png) [@k4rtik](https://meta.discourse.org/u/k4rtik)
#### Post date: [June 11, 2020, 4:19pm UTC](https://meta.discourse.org/t/locations-plugin/69742/555 "2020-06-11T16:19:05Z")

</div>

A bug report.

This bug has been around for a while, but I finally figured out the locations plugin is to blame. When I have the plugin disabled, my website shows up correctly on the user card, but when I enable it, it shows up twice! Here’s a screenshot from the user card that appears on hover:

 ![Screen Shot 2020-06-11 at 11.13.52 AM](https://global.discourse-cdn.com/meta/original/3X/e/3/e3a5e9438bc9ed2c4c39566f19fc9288cc1ea462.png)

and another from the fully expanded profile page:

![Screen Shot 2020-06-11 at 11.15.36 AM](https://global.discourse-cdn.com/meta/optimized/3X/0/3/032db70290b4785e318d7e9f9f845f97f0eb1a27_2_690x63.png)

I have tested this many times by playing with combinations of changing the values in the profile. The only time I see it appear correctly, that is the website shows only once is if I disable the Locations plugin.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [June 11, 2020, 4:41pm UTC](https://meta.discourse.org/t/locations-plugin/69742/556 "2020-06-11T16:41:40Z")

</div>

Thanks Kartik, are you on a recent update?

---

<div class="post-metadata">

### Author: ![k4rtik](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/k4rtik/32/119508_2.png) [@k4rtik](https://meta.discourse.org/u/k4rtik)
#### Post date: [June 11, 2020, 4:52pm UTC](https://meta.discourse.org/t/locations-plugin/69742/557 "2020-06-11T16:52:35Z")

</div>

Yes, I should have mentioned it.

* * *

EDIT: The HTML generated for the duplicate element:

```plaintext
<span id="ember858" class="ember-view"> <div id="ember860" class="user-location-and-website-outlet replace-location ember-view"><!----><div class="user-profile-website">
  <svg class="fa d-icon d-icon-globe svg-icon svg-string" xmlns="http://www.w3.org/2000/svg"><use xlink:href="#globe"></use></svg>
    <span title="http://ks.cs.uchicago.edu">ks.cs.uchicago.edu</span>
</div>
</div>
</span>

```

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [June 11, 2020, 5:01pm UTC](https://meta.discourse.org/t/locations-plugin/69742/558 "2020-06-11T17:01:31Z")

</div>

I’m tied up with client work atm, but will keep this one in mind in the run up to the next supported upgrade period (1-5th of next month).

---

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [June 11, 2020, 5:07pm UTC](https://meta.discourse.org/t/locations-plugin/69742/559 "2020-06-11T17:07:13Z")

</div>

Interesting that one is styled as a clickable link and the other is not 🤔

Also interesting that we’re not seeing this issue on our forum.

---

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [June 21, 2020, 11:29am UTC](https://meta.discourse.org/t/locations-plugin/69742/560 "2020-06-21T11:29:18Z")

</div>

We seem to have another issue @merefield

Our user map is currently showing 472 users, but a few users have reported that their pin is not showing on the map. Yet when you view their user card, they are showing on their own little map.

When we run a query on the database for users with a location added, we get 492 results, so it looks like 20 or so are not visible on the map.

Can we do anything to help debug this one?

Viewing Chris’ user card, he displays on his own map profile ok:

 ![image](https://global.discourse-cdn.com/meta/original/3X/6/e/6ed26218ff47d69bf4478ca7b9e18d73bd5dc314.jpeg)

Full / main map, Chris is missing 🤔

 ![image](https://global.discourse-cdn.com/meta/original/3X/0/4/044513a0013d8135e862567fe5eb1d53bec2695e.jpeg)

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [June 22, 2020, 8:42am UTC](https://meta.discourse.org/t/locations-plugin/69742/561 "2020-06-22T08:42:38Z")

</div>

What’s the value of this setting, Richie?

![image](https://global.discourse-cdn.com/meta/original/3X/4/a/4ab835e427efa6e1d93097d92b39ae9c3ed77d0f.png)

for the example missing user, can you please PM me the result of this from the rails console:

```plaintext
myuser = User.find_by(username: "===USERNAME===")
myuser.custom_fields["geo_location"]

```

---

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [June 22, 2020, 3:51pm UTC](https://meta.discourse.org/t/locations-plugin/69742/562 "2020-06-22T15:51:49Z")

</div>

> [@merefield](#):
>
> What’s the value of this setting, Richie?

The plot thickens 😃

It was set to 500.

I changed it to 1000 and our missing people instantly appeared 🤔

I’ll PM you the results as requested 👍🏻

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [June 22, 2020, 3:54pm UTC](https://meta.discourse.org/t/locations-plugin/69742/563 "2020-06-22T15:54:55Z")

</div>

Ah, in which case there is no need to PM that information. I suspect that the list of people with geo\_locations might have included ones with blanks there (custom field exists but empty object for example) and as a result you might be tripping the max number. Increase the max number and even though there are blanks, they don’t push out the valid users. Definitely could improve the code there, but not critical.

---

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [June 22, 2020, 3:58pm UTC](https://meta.discourse.org/t/locations-plugin/69742/564 "2020-06-22T15:58:25Z")

</div>

Thanks @merefield we have seen a couple of users with things like `'{}'` in their value so I’m guessing they may once had a location and it’s since been removed.

I also can’t remember if those values get deleted when a user is anonymised - again it would trip us over the magic 500 value that we had set.

Cheers 🙂

[Previous page](https://meta.discourse.org/t/locations-plugin/69742.md?page=3)

[Next page](https://meta.discourse.org/t/locations-plugin/69742.md?page=5)
