How to use a field value in a json string?

98 views
Skip to first unread message

Beckstrom

unread,
Mar 6, 2020, 7:53:41 AM3/6/20
to TiddlyWiki
Hi all,

First of all this is probably the most awesome and useful piece of software I’ve ever used. I love it!

I’ve been trying to figure out how to include a map automatically in any tiddler that is a “place,” for instance “starbucks on main” or “Belgium.” I’ve been trying to use the Leaflet Maps plugin from here: http://sycom.github.io/TiddlyWiki-Plugins/

According to the docs, if you add a field called “point” or “points” and put a comma separated list of the lat/lon(eg 45.3347,-85.72882) you can access the field and generate the map

It works if I hardcore latitude and longitude when I call the widget, like this:

<$leafmap tile='sat'
places='{"point":"6.5,19.72" />

but i can’t figure out how to dynamically access the “point” field for tiddlers. I’ve tried all sorts of things, such as

<$leafmap tile='sat'
places='{"point":"{{!!point}}" />

It seems like no matter what i do, the variable is not expanded because of the double quotes inside the json.

Any idea how I could make this work? Please and thanks in advance for your help!!

Sycom

unread,
Mar 6, 2020, 10:34:03 AM3/6/20
to TiddlyWiki
Hi Beckstrom,

if your tiddler is actually a geoTiddler (i.e. it has at least one point(s), line(s), polygon(s), place or geojson field) it should automatically display a map at the bottom of the tiddler.

This behaviour is defined through the $:/plugins/sycom/leaflet/templates/geoTiddler tiddler. You may edit this one to modify default appearance of the map or disable it.

I'm not sure how your wiki works or what you want to do. If you have geoTiddlers you can map them directly :

<$leafmap places='{"tiddler":"Belgium"}' />

or through a filter
<$leafmap places='{"filter":"[tag[country]tag[Europe]]"}' />

Due to leaflet map widget syntax, I'm afraid that "dynamic call" should be made through macros you will have to define locally or globally (see https://tiddlywiki.com/#Macro%20Definitions%20in%20WikiText). Very unsure about your success with this strategy since the plugin was not designed for this...

If this is not the behaviour you expected, feel free to share (a part of) your wiki and describe what you want to achieve. I have not much time now since I just started a new job, but I will try to help you asap.

cheers,

Sylvain
@sycom

Beckstrom

unread,
Mar 6, 2020, 10:59:00 AM3/6/20
to TiddlyWiki
Aha, thank you so much for the reply! I'm not sure what happened but this seems to be working now after a reinstall of the plugin. I think I maybe messed up the original view template.

At any rate, this seems to be working for my wiki now. Thanks for your help, and for creating such a cool plugin!

TonyM

unread,
Mar 6, 2020, 6:19:44 PM3/6/20
to TiddlyWiki
Folks a slight diversion.

I am a keen user of what3words which has a three word name for every 3m x 3m square on earth. One advantage is the location is easy to read, available in multiple locations and can be easily shared by voice over the phone, with other share options available.

There are API's and mapping available and this would integrate well with tiddlywiki and leaflet. Happily each location tiddler can be named with a location name eg; guard.cling.radio

This 3 word address refers to an exact 3m x 3m location. Tap the link or enter the 3 words into the free what3words app to find it.

Regards
Tony

Beckstrom

unread,
Mar 6, 2020, 9:19:20 PM3/6/20
to TiddlyWiki
So I think I spoke too soon... there's something weird going on, strange behavior. Here's what happens:

- I create a tiddler with a field called "point" and set the value to something like 24,-82
- I save the tiddler
- I can see the map, and there is a marker at the lat/long I specified
- If I close the tiddler and re-open it, it works fine (map appears as expected)
- But if I either reload the wiki (from the "reload" button in the sidebar) or refresh the page or in any way view that same tiddler again, I get a javascript error popup.

It says:

Internal JavaScript Error

Well, this is embarrassing. It is recommended that you restart TiddlyWiki by refreshing your browser
TypeError: flds.text is undefined

Looking in the javascript console, I see:

TypeError: flds.text is undefined line 15899 > eval:506:25
    mapTiddler $:/plugins/sycom/leaflet/mapWidget.tid:506
    mapPlaces $:/plugins/sycom/leaflet/mapWidget.tid:228
    execute $:/plugins/sycom/leaflet/mapWidget.tid:188
    render $:/plugins/sycom/leaflet/mapWidget.tid:69
    renderChildren $:/core/modules/widgets/widget.js:391
    render $:/core/modules/widgets/list.js:300
    renderChildren $:/core/modules/widgets/widget.js:391
   .... .... etc ... ..

Any idea what might be causing this?

On Friday, March 6, 2020 at 10:34:03 AM UTC-5, Sycom wrote:

Beckstrom

unread,
Mar 8, 2020, 1:11:53 PM3/8/20
to TiddlyWiki
after a whole lot of troubleshooting, I think i figured out what was causing this weirdness! my server was set to lazy-load all, including tiddlers, and that seems to have been messing with this plugin.

I disabled lazy-loading for tiddlers and this is now working great! thanks for your help!

Sylvain Comte

unread,
Mar 9, 2020, 4:30:05 AM3/9/20
to tiddl...@googlegroups.com
Hi,

Glad you found a way to go. I was disconnected this weekend, so I didn't see your messages...

I'll take a deeper look at this to avoid TW crash. When I got time :-/

cheers,

Sylvain
@sycom


On Sun, Mar 8, 2020 at 6:12 PM Beckstrom <chrisbe...@gmail.com> wrote:
after a whole lot of troubleshooting, I think i figured out what was causing this weirdness! my server was set to lazy-load all, including tiddlers, and that seems to have been messing with this plugin.

I disabled lazy-loading for tiddlers and this is now working great! thanks for your help!

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/J2yT7nqCF4g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/04e2e77e-ffb6-4fee-8daa-72bf44279f08%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages