Saturday, 30 October 2021

Announcing: mapguide-react-layout 0.14.3

This release improves upon the 0.14.2 release with the following changes:

The viewer now supports static images as a subject layer in an application definition JSON document. This allows the viewer to display any arbitrary image, allowing one to display "maps" that have no real-world geographic basis. For example, you can now use the viewer to view the fictional map of Los Santos


Or if fantasy is your thing, maybe a map of Middle Earth


Because static image layers have no real-world geographic basis, it is incompatible with layers and widgets that assume your map is based on a real-world coordinate system, so things such as:

  • XYZ, OSM or Bing Maps Layers
  • Coordinate Tracker widget
Will not work with static image layers and will be disabled if you load in an appdef document that has a static layer and one or more of these layers/widgets specified. A viewer static image subject layer will also be operating in stateless mode, so all the caveats and limitations of stateless mode also apply.

On the same topic, the viewer now also supports MapGuide Map Definitions based on arbitrary unit coordinate systems. Map Definitions based on arbitrary coordinate systems are typically things like internal building floor plans or maps whose layers are sourced from non-georeferenced CAD drawings. Again, the same limitations as static image subject layers apply (no XYZ/OSM/Bing backdrops, etc, etc)

For this release we've also extracted the layout-template-specific CSS out to their respective stylesheets. This means that the HTML content for all the viewer template files are now 99% identical with the difference being the template stylesheet reference and the template name to init the viewer with.

The HTML is such that you could now conceivably create a server-side wrapper that can generate the viewer HTML for any template given the name of the template to use. This release includes a new optional index.php entry point that pretty much demonstrates this idea. The index.php entry point takes a template query string parameter in addition to all the other query string parameters and will render out the viewer in your chosen template.

This release also fixes the following issues:
  • Init warnings now display again on startup
  • Transparency is now properly applied for non-MapGuide subject layers

Friday, 15 October 2021

Announcing: mapguide-react-layout 0.14.2

This release improves upon the 0.14 release with the following changes:

A new XYZDebug base layer type is available to view debug tiles with XYZ coordinates

To add a XYZDebug layer, add a XML fragment like the following to your application definition document.


The purpose of this layer is simply to assist in debugging/identifying XYZ tile coordinates relative to the map you're looking at. It's loaded like any other base layer, so you won't see it overlaid on top of your map. To see it you'll need to change the transparency of the main map in the Viewer Options.

The other noticeable change is that the Select tool now has a flag that toggles whether this tool can pan via mouse drag, as demonstrated in this recording below.


This allows mapguide-react-layout to behave more like the simplified web maps like Google Maps instead of GISes where selection and panning are 2 separately distinct functions.

The final change is that the Refresh Map command no longer tries to request an updated MapGuide runtime map layer/group structure when the viewer is in stateless mode.

Download

Thursday, 7 October 2021

Announcing: mapguide-react-layout 0.14

And here it is! A new major release of mapguide-react-layout.

The release marks a turning point where the map viewer no longer has a hard dependency on a MapGuide Server to function allowing it to be used in more general purpose contexts that may or may not involve a running MapGuide Server.

Not to mention, a whole lot of new features that have already been covered previously.

Download

Saturday, 2 October 2021

mapguide-react-layout dev diary part 26: Making the map viewer general purpose

Previously, I hinted that the future of mapguide-react-layout besides having a new name (I still haven't come up with a suitable replacement on that front) is to make the map viewer general purpose so that it can be used in contexts that do not require a dependency on a running MapGuide Server.

As I am wrapping up development on the upcoming 0.14 release, I figured it's time for a new dev diary entry that details how we have reached this goal. So strap in. This is going to be a big post with images and embedded webms galore!

MapGuide Support is now optional

To make our viewer general purpose, we have to be able to load in an Application Definition where the primary Map element does not refer to a MapGuide Map Definition, but instead refers to what I like to call a "subject layer". The "subject layer" is the layer of focus for any given map and can be:
  • A WMS layer
  • A vector layer
To demonstrate how truly de-coupled we are from requiring a running MapGuide Server, I present to you a new generic viewer template powered by this example application definition document. All the map groups in that example refer to subject layers instead of MapGuide Map Definitions and thus does not require any dependency on a running MapGuide Server.

New "generic" viewer template

The new "generic" viewer template is a minimal and opinionated viewer template geared for use in a general purpose context (without a MapGuide Server).


The template is opinionated in the following sense:
  • The commands in the vertical toolbar is pre-defined. You cannot customize the contents through the application definition. This template does offer a configurable context menu.
  • The UI is intentionally kept as minimal as possible. There is no Task Pane in this template. Invoke URL commands will load content into floating modal windows. Certain toolbar commands (like the layer manger and selection panel) will load their UI content into drawers.
Although this template is geared for use in a general purpose context, it still can be used with a MapGuide Server as demonstrated below with the Sheboygan dataset



In the MapGuide context, several extra toolbar buttons are enabled. The toolbar differences are outlined below



Supercharged External Layer Manager

For the upcoming release, the External Layer Manager gets several major enhancements.

Firstly, vector layers now have fully declarative styles with editor support in the External Layer Manager UI. With declarative style support, when adding a new file-based vector layer, you have several choices regarding how the layer is to be added.

You can now choose to create a thematic layer with a pre-defined colorbrewer ramp and optional labeling.




For point-based layers, you may choose to add it as a clustered point layer



Or alternatively, as a heatmap layer


For non-heatmap vector layers, you can view and edit the styles to your liking


General-Purpose-ing various components

There are various components that were previously MapGuide-specfic and would be somewhat pointless in a general purpose context. As some of these components are permanent fixtures in some viewer templates, we have to make them somewhat useful in a non-MapGuide context if said template is fed a non-MapGuide appdef.

The Legend component now also displays the list of external layers in its own root category, essentially acting as a compact version of the layer list from the External Layer Manager UI.


The Selection Panel component will now also display attributes of selected client-side vector features.


UTFGrid support

UTFGrid layer support was introduced in the 1st preview release of MapGuide Open Source 4.0. To better advertise this new feature, the viewer supports UTFGrid layers if specified as part of a MapGroup element in an application definition like so


With this XML fragment in place, loading the appdef into the viewer will cause a UTFGrid interaction layer to be created as part of viewer initialization and will manifest as feature tooltips that display on mouse hover.


There is one caveat with UTFGrid support in mapguide-react-layout. You must pair this up with a Map Definition that is in the WGS84.PseudoMercator (aka. EPSG:3857) coordinate system.

"Stateless" mode for MapGuide maps

UTFGrid layers go nicely with another new feature of mapguide-react-layout: Support for "stateless" mode.

In stateless mode, the viewer:
  • Does not create any session ids
  • Consequently, it does not issue any CREATERUNTIMEMAP requests on viewer startup
  • Will render maps using GETMAPIMAGE instead of GETDYNAMICMAPOVERLAYIMAGE
Because no session id is ever created, the viewer can't use commands that require a SESSION/MAPNAME pair, such as:
  • Buffer
  • Query
  • Theme
  • Redline
  • Feature Info
  • Quick Plot
  • Select Within
Such commands if present in the application definition will be permanently disabled in any toolbars and menus where they are referenced in. The viewer will log console warnings about such unsupported commands in stateless mode (as a hint for you to trim out such commands/widgets from your application definition if authoring up a stateless appdef).

Because CREATERUNTIMEMAP requests are not sent in stateless mode, we have a less rich layer/group structure to work with.

Compare the Legend for a stateful version of the Sheboygan map


Versus the stateless version


In the stateless version, we only have the basic layer group structure (computed from the Map Definition resource we fetch on startup) to work with. As a result, we do not have information such as:
  • Visible scale ranges for layers
  • Style/theme icons for layers
While technically possible, it is currently impractical to fetch all the required Layer Definitions for this information (we would be spamming our MapGuide Server for layer definition requests if loading up a really heavy Map Definition).

Why would you want to use stateless mode? If the caveats listed above are not deal breakers for the type of web map you are trying to serve, stateless mode presents a much more scalable map viewing option in MapGuide as there are zero MapGuide sessions being created or managed, reducing load/memory burden on the MapGuide Server.

Stateless mode is an opt-in feature. You can opt-in to stateless mode by adding a Stateless extension property to the Application Definition like so.


The stateless mode extension property has no effect if your appdef is general-purpose (ie. It does not reference any MapGuide Map Definitions). General-purpose appdefs are implied to be stateless already.

Other notable features/changes

Client-side vector layers are now hover-able (to better hint that they're selectable)


The fusion print command/widget is now supported. You will no longer get an error placeholder in toolbars and menus where this command/widget was referenced. This command will export the current map image out to a separate ready-to-print browser tab.


The previous WMS layer selection tool has been incorporated into the regular Select tool, making it the final one-stop-shop for selecting anything, be it MapGuide layers, WMS layers or client-side vector layers. Also when the Select tool is active, you can now still pan via middle-click mouse drag.

In Closing

Expect the 0.14 release of mapguide-react-layout to come out soon. I am just finishing up documentation aspects of this release.