Introduction to the Geospatial Plugin

Hmmm, I had to do that several times before I asked the question; it seems to want me to wrap numeric values in Strings. So I thought I had done everything right there, and all my tiddlers seemed right. But I wanted to prove it to myself, and I regenerated everything from scratch, including a new randomized selection of addresses, and it worked fine!

I’m still not sure why. I am wondering if I was simply missing the (somewhat subtle) green circles that bundled additional locations, and it coincidentally, the number shown at my magnification happened to be ten with ten additional ones bundled. But I no longer have that version to check.

I’m curious what JSON you’re referring to. The data I’ve looked at on the demo page is all in individual tiddlers, not in a JSON bundle. In any case, my current attempt is modeled on “Map with Geomarker” inside $:/plugins/tiddlywiki/geospatial/docs/geomap, which uses individual tiddlers (cities/Oxford, cities/New York, etc.)

Thank you for the help. I’ve off to investigate the next problems, but my current progress now feels good: https://crosseye.github.io/TW5-demos/2023-10-07a/.

eg: If you edit the tiddler: Geospatial Plugin — Geographic Data Features for TiddlyWiki

Sometimes it’s enough to miss a , somewhere.

Ah, yes, I hadn’t spent any time with the shapes demos, thank you.

It certainly can be. I tend to generate such data programmatically, in good part for that very reason. It wasn’t an issue here, but thanks for the reminder!

Thanks @Scott_Sauyet. In fact, the getquerystring operator is no longer needed, so I’ve removed it. The alternative is to use the query-* parameters with the tm-http-request message.

Sylvain Comte’s Leaflet maps plugin is excellent, and has been deservedly popular since its debut in 2016/7. There are a lot of similarities with the geospatial plugin because it integrates the same mapping library and uses the same GeoJSON format for data. I think the notable differences are:

  • The scope of the geospatial plugin is wider, and includes geospatial calculations (eg difference, overlap of regions) from a library called Turf.js, and support for some geospatial APIs
  • The geospatial plugin takes advantage of some newer core facilities and techniques to be more tightly integrated with wikitext. For example, the Leaflet plugin uses a places attribute that contains a JSON definition of the tiddler data to be plotted. In the geospatial plugin a separate <$geolayer> widget is used for each item to be plotted. This means that there are fewer JSON strings needed to get things going
  • The geospatial plugin exposes some lower level features. For example, the Leaflet plugin requires editing a JSON tiddler to add support for a different background layer provider. In the geospatial plugin, the <$geobaselayer> widget can be used to directly add a background layer provider

In short, if you are already using the Leaflet plugin and are happy with its functionality there is no pressing need to upgrade. If the additional functionality of the geospatial plugin is of interest then I think the migration path would be straightforward, and only require changing a few templates and not your underlying data.

1 Like

Looking at your example, is it just that clustering is enabled by default, so the markers that are close together are coalesced into a green circle that is quite hard to see in this context? I can see all twenty markers if I click on the green clusters to expand them.

I think that was probably it. I saw the circles in this demo. I didn’t keep the original demo where it seemed to be failing – but as far as I can tell, the only difference was a different random subset of my addresses. I may have just seen the round number of ten visible and make a bad guess.

I’m hoping to get back to this in a few days, but first I need to build the UI to allow someone to enter the data. Thanks for the reply!

Is there an easy example of <$geobaselayer> to utilize an alternative tiles-url?

Long-time lurker, infrequent commenter here.

I’m trying to use GPX files with the Geospatial Plugin, but I’m having issues. First, I tried entering the GPX data into a tiddler and changing the type to Application/JSON, but that causes a Javascript error when I try and map it. Next, I tried converting the GPX to GeoJSON, putting the GeoJSON into a tiddler and mapping it, but that didn’t work until I split the GeoJSON into separate files for lines and for points. The lines map and points map correctly (as in, their location), but the popups only show the last label in the file.

In addition, the popups are just displaying the unformatted GeoJSON content: “{ “popupContent”: “Florida Keys” }” rather than correctly as: “Florida Keys”. I’ve tried changing the “popupContent” property to everything I can think of (“name”, “ID”, “label”, etc) but it always displays the same way and it’s always the text from the last feature in the file.

Any thoughts on where I’m going wrong?

Here’s the GPX and 2 GeoJSON tiddlers that I have:

EDT-S8-GPX.tid (628.7 KB)
EDT-S8-LINES.tid (174.6 KB)
EDT-S8-POINTS.tid (55.6 KB)

Here’s the code for generating the map for Segment 8 (the last of 8 segments):

Route Map for Segment 8 - Cypress.tid (344 Bytes)

1 Like

Hi @MrBatman777 I am very sorry that I missed your post.

The Geospatial plugin doesn’t support GPX, which is an XML based format.

I think that would be a limitation of Leaflet.js, all we’re doing here is handing it the block of GeoJSON.

The popup support is unfinished. I would really like to be able to include rendered wikitext within the popups but if that is not feasible it most be possible to support providing a user defined function that converts a blob of JSON properties to a text string.

1 Like

The Geospatial Plugin has now been merged to the prerelease, and is planned to be included in TiddlyWiki v5.3.4 next month.

The demo can be found at https://tiddlywiki.com/prerelease/plugins/tiddlywiki/geospatial/

4 Likes

Very cool!

Tiny glitch: it seems the popupContent is nesting inside itself currently:

Thanks Jeremy!

I went back to using the Leaflet plugin and it’s working fine. It doesn’t have some of the features that (I think) the Geospatial plugin has, namely the ability to calculate the length of a multi-segment line, but I added that myself. I’m not sure that the popup only displaying the last label in the file is a problem with Leaflet.js because it works fine in the Leaflet plugin and isn’t that based on Leaflet.js as well? I’m sure I’ll try the Geospatial plugin again at some point, but for right now Leaflet works well enough for my purposes. Thanks again for getting back with me!