Styling Your Data

In the previous Quick Start chapter we published our first map. In this chapter we’ll learn about styling published maps and will make the background maps less busy and assign a sensible style to our green spaces data.

_images/first_map.png

Back to QGIS

In order to change the styles of the layers in Mappin, we’re going to change the way they look in QGIS and then upload the project again.

Let’s start with those background maps. The background map layer, OSBackgroundMaps is a WMTS layer (tile-based maps). To QGIS it’s still a raster layer and we can overrride how raster layers are displayed. We’ll tone down the colour (hue) in the layer to make the foreground maps stand out better.

  1. Open your project in QGIS
  2. Double-click the OSBackgroundMaps layer in the Layers Panel in QGIS
_images/os_bg_layers.png

Now with the layer properties open we can change the way the backround maps are displayed.

_images/bg_hue_qgis.png
  1. Select the Style tab
  2. Change Brightness to 80 and Contrast to -40
  3. Click OK

You should now see the improvements in the background mapping:

_images/improved_bg.png

As QGIS loads vector layers with random colours, your green spaces may not be green. We’ll change that now - making them green with a dark green outline.

  1. Double-click the GreenspaceSite_Sheffield layer in the Layers Panel in QGIS
  2. Select the Style tab
  3. Update the Fill and Outline colours to green and dark green
  4. Change the Outline width to 1.5 Pixels
  5. Click OK

Please note that measurements in styles and labels in map units or mm may not look the same when published using Mappin - this is because QGIS is most likely displaying the maps on your computer in a different DPI setting than the one used in the WMS standard. Using measurements in pixels should mean the maps on your screen will look the same when published in Mappin.

_images/foreground_style.png

Nice- now our green spaces are green:

_images/green_green_spaces.png
  1. Save your QGIS project

Seeing the Changes in Mappin

Now we’ve updated our QGIS project, let’s upload it to Mappin (FIXME).

With our updated project uploaded, we expect that our published maps will now reflect our recent changes, having lighter background maps. You may have noticed that this is not the case and (in at least soem areas) the map still looks the same as it did initially. This is because Mappin has cached some of the map tiles (stored tiles it’s already drawn on disk so it can simply re-send these later when requested rather than having to draw them again).

We’ll now temporarily disable this cache so we can effectively preview the new map styles.

  1. In the Mappin Administrator interface, go to the Cache Settings section
  2. Select Caches and default_view_cache
  3. Enable the Disable Storage option
  4. Click SAVE CHANGES
_images/disable_storage.png

default_view_cache is a Cache that’s created automatically by Mappin based on the layers that are visible by default and aims to improve performance of initial map loads. We’ll learn more about caches laster. By changing the Disable Storage option, Mappin will no longer cache the default view (meaning we should see our updated styles).

  1. Reload/refresh (CTRL+R) the project in Mappin to ensure your browser gets the latest map data from Mappin
_images/updated_style_in_mappin.png

Now we can see our maps looking as we wanted them to.

Although Mappin supports caching of layers, support for seeding (pre-populating) or dropping/invalidating a cache have not yet been implemented. For these reasons, cached map tiles in Mappin have a lifetime of 24 hours after which time they expire (are deleted). This should provide some balance between performance (having the ability to cache tiles) but also being able to update layer styles. Where you would normally invalidate / delete a cache, in the current Mappin release, you just need to wait 24 hours for the stale cache tiles to expire.

Please note that we also disabled caching for the default_view_cache cache above - we’ll leave this off for now and will experiment more with cache settings in later chapters.

Legend Images

Let’s take a look at Mappin’s legend:

_images/default_legend.png

Notice the background maps also have an entry there - we’ll now disable legend images for the background mapping layer as it’s not really appropriate to display one.

  1. In the Mappin Administrator interface, go to the Layers section
  2. Select Background Map
  3. Change Legend Mode to Hide
  4. Click SAVE CHANGES
_images/hide_legend.png
  1. Reload/refresh (CTRL+R) the project in Mappin

The legend should now only display an image for our green spaces layer.

_images/legend_fixed.png

The same setting we just used to hide legend images can also be used to specify an uploaded image file to use for a layer’s legend image.