Leafmap plugin - how can I draw a polyline from Tiddlers point field?

I have Tiddlers with the tag [place], that are tagged with a specific tag that group them as a trip, say that this tag is [trip].

This tiddlers are listed using

<$macrocall $name="list-tagged-draggable" tag={{!!viaggio-scelto}} class="nobullet" itemTemplate="TemplateViewRigaViaggio" />
And is working.

I want to use the <$leafmap> plugin to draw a polyline betwen the tiddles to visually understand the path.

So if I have in the list a place near one that in non connected or is connected in a bad way I can drag places and find the best ordered list of places.

I was able to draw polyline from a tiddler using the field “polyline” but I can’t use existing Tiddlers that have the field “point” to draw a two point (and afterwards with more points) polyline.

<$leafmap tile='osm' places='{"point":"6.5,19.72","polyline":"6.4,19.7 6.6,19.74"}'/>

From documentation I can pass point filtering but I failed.

How I can pass the field “point” from my list of tiddlers to the polyline?

Thanks

Perhaps and existing user of this plugin can help, the plugin repository is here and perhaps you can raise an issue there but it seems quiet.

Have you tried adapting the example from the documentation:

<$leafmap tile='toner'
	places='{"filter":"[all[shadows]tag[example]]"}' clusterType='tiddler'/>

With your data this might look something like this:

<$leafmap tile='osm'
	places='{"filter":"[all[tiddlers]tag[place]tag[trip]]"}' cluster=''/>

Each tiddler that is part of the trip can have its own polyline or point field.

Yes I have a tiddler with this exact code and it is working.

My idea was different.
I want to plot a line from point to point where the points are the coordinates of the tiddlers tagged [place] in order to visualize strange paths.

Not being familiar with the plugin, it is difficult to understand the difference between what the proposed code outputs and what you desire. Does passing a filter not plot a line from the points given in each tagged tiddler?

Could you please explain the difference, and also post a sample TiddlyWiki with some test data where this can be tested?

1 Like

I have “published” the Viaggi — Viaggi e Tempo Libero (ver. 2022-05-10) (tiddlyhost.com) that is my work in Progress at the moment.

At start it open four tiddlers:

“Scheda Viaggio” and “Scheda Viaggio Mappa” are working.
“Inizio” is the main index of the future TW.

“Scheda Viaggio Point to Point” is the work in progress, I’m trying to plot a polyline from the points of the place tiddler.

I hope this can explain what I’m doing.

I get that Torino is great … vera …

TT

1 Like

At a quick glance I see a few problems with your code:

  • You are using the $(variable)$ syntax for text substitution which only works inside of macros, so the text substitution never happens in your example tiddler.
  • The format for your point fields seems wrong. The documentation ask for x,y format whereas your points are x, y format, note the extra space after the comma. I think this creates problems when passing in multiple points together as the space is what indicates where one point finishes and the next one starts.
  • to get a polyline from points the way you are trying to pass them in, I think you need use the polyline JSON index rather than places.

Try the following after correcting the syntax of the point field in the tiddlers:

\define my-map()
<br>
<br>Sono presenti <$count filter="[all[]tag[luogo]tag[Biella e Canavese]" /> luoghi e <$count filter="[all[]tag[percorso]tag[Biella e Canavese]]" />  percorsi.
<br>
<$leafmap 
    tile='osm' 
    cluster="40"
    places='{"polyline":"$(punti)$"}' 
    />
\end

<$set name="punti" filter="[tag[Biella e Canavese]get[point]enlist-input[]unique[]]">
<<my-map>>
</$set>

This made the magic!
I’ve added a search-replace[ ],[] after the get[point] and with your code worked!

\define my-map()
<br>
<br>Sono presenti <$count filter="[all[]tag[luogo]tag[Biella e Canavese]" /> luoghi e <$count filter="[all[]tag[percorso]tag[Biella e Canavese]]" />  percorsi.
<br>
<$leafmap 
    tile='osm' 
    cluster="40"
    places='{"polyline":"$(punti)$"}' 
    />
\end

<$set name="punti" filter="[tag[Biella e Canavese]get[point]search-replace[ ],[]enlist-input[]unique[]]">
<<my-map>>
</$set>
1 Like