Setting the default map for the Leaflet map plugin

Here is another (hopefully) useful tip for the Leaflet map plugin.

If you edit the shadow tiddler $:/plugins/sycom/leaflet/mapWidget.tid you can change the default map for a GeoTiddler (i.e. a tiddler with a point, points, polyline, polylines fields etc.) Normally the default is “osm” but you can change it to “sat” for example.

Change these two lines:

setting.tile = this.getAttribute("tile", "osm");

setting.tile = "osm";

replacing “osm” with “sat” or another of your tiles.

Thanks for the tip. There is a parameter to override the default tile. When I use it in a macro I pass in the tile. In this way, I have my own tile setting that a user can select as a default tile to use. (Something that would have been best implemented in leaflet plugin). This illustrates it…

\define showmap(maptype)
<$leafmap tileControl tile='$maptype$' places='{"filter":"[tag[event]each:list-item[place]has[point]]"}' cluster='30' />
\end

<$macrocall $name=showmap maptype={{$:/config/cls/collection!!default-leafmap}} />

In a settings tiddler I provide a way for the user to use a dropdown to select the default. This sets field default-leafmap in $:/config/cls/collection.

A bit more complicated.