Locations Plugin

(Angus McLeod) #61

@meglio @ChrisBeach @Stephan_Eich I appreciate the thought guys, but there’s no need. You have already repaid me by giving great feedback and advice. We all contribute in different ways. You can buy me a real beer next time I come to Ukraine / UK / Germany.

@meglio :+1: pr merged.

(Chris Beach) #62

Let me know when you next come to London. I will buy you that beer!

(Stephan Eich) #63

And Berlin is a nice town. Let me know as well.

(Anton) #64

And Adelaide. That’s where I moved 3 years ago.

(Angus McLeod) #65

I’ve added address localization in the form of the user’s effective_locale. If the user is allowed to set their own locale, that is used. If they are not, the site locale is used. The localization itself is handled by each geocoding service via the Geocoder gem.

(Angus McLeod) #66

I’ve added location topic status icons. There are both site and category specific settings for it.

(Angus McLeod) #67

Similarly to the Events Plugin, I’ve made a tweak here so locations can be posted via the api.

So you can now do this:

curl -X POST \
  https://your_domain/posts \
  -H 'cache-control: no-cache' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F api_key=your_key \
  -F api_username=your_user \
  -F 'title=We'\''ll have a whale of a time :whale:' \
  -F 'raw=Put on the beach boys and surf the day away.' \
  -F category=Events \
  -F 'location={"geo_location": {"lat": "-3.1667533","lon": "-161.2040476","address": "Middle of the Pacific Ocean"},"name": "The Middle of Nowhere"}' \
  -F 'event={ "start": "2017-10-18T10:08:08Z", "end":  "2017-10-18T11:08:08Z" }'

And get this:

The location JSON string needs geo_location with a lat, lon and address. The address is what is displayed in the location labels in the UI. name is an optional place name.

As you can see from the example on my sandbox you can pass arbitrary lat and lon. @Stephan_Eich You may find that useful.

(Anton) #68

@angus, thanks for quick updates.

Feature request - toggle showing closed topics on a map. Would it be possible to add a per-category setting to turn on/off placing markers on a map for closed topics?

(Admir Hodzic) #69

@sam @codinghorror can We get subcategory for this plugin,
It is hard to read and compile all requests replays,
I have few in my mind but I do not want to overflow this topc

(Jeff Atwood) #70

No, I don’t think that’s necessary at the current time.

(Jay Patel) #71

After installation of plugin i get this error also change in Theme. any idea what could be wrong?


(Angus McLeod) #72

You need to update. The missing sass variable (which is causing the error) was added 15 days ago.

(Jay Patel) #73

My discourse version is v1.8.9 +1 still getting same error.

(Angus McLeod) #74

Fair enough. I’ve reverted to the older variables for now @Jay_Patel

(Jay Patel) #75

Hi ,
Thanks @angus for changes. It seems plug-in installed properly but its showing like this on created topic under category: BSDCan BSD Conference 2018 - Events/Conferences - UnitedBSD

Thanks in Advance,

(Angus McLeod) #76

The error on that page is d-icon is not a helper

d-icon was added to Discourse master 3 months ago and has been in a number of releases since then.

In this case, you’ll need to update if you want to use this plugin.

(Jay Patel) #77

okay. i will try in next version probably because i am on latest stable.


(Angus McLeod) #78

This plugin now has a few of different backend hooks which can be used to add additional logic in a separate plugin to fit a particular use case.

Geocode results filter: Locations::Geocode.add_filter { |locations, context| #your logic }

Geocode results validator: Locations::Geocode.add_validator { |geo_location, context| #your logic }

Geocode custom search options: Locations::Geocode.add_options { |options, context| #your logic }

Map list results filter: Locations::Map.add_list_filter { |topics| #your logic }

To ensure the Locations plugin is loaded (plugins are loaded alphabetically) you can use the event :locations_ready to add your custom logic.

For an example, see the Events plugin:

DiscourseEvent.on(:locations_ready) do
  Locations::Map.add_list_filter do |topics|
    if SiteSetting.events_remove_past_from_map
      topics = topics.joins("INNER JOIN topic_custom_fields
                             ON topic_custom_fields.topic_id = topics.id
                             AND topic_custom_fields.name = 'event_end'
                             AND topic_custom_fields.value > '#{Time.now.to_i}'")



The “location category map filter” isn’t displaying on the updated discourse build (1.9.0.beta14). Is anyone else experiencing this?

(Angus McLeod) #80

Working fine for me. See here.

Have you enabled the setting?