Home

Awesome

Maperture: Stamen's map compare tool

Maperture Science

A web application for comparing webmap styles.

View a demo here.

gif demo

Get started

  1. Install the dependencies: yarn install
  2. Make a local config module: cp public/config/local.example.js public/config/local.js and edit the config file as appropriate
  3. Start the dev server: yarn dev

Building and running in production mode

  1. Create an optimised version of the app: yarn build. If you will serve the built app from a subpath such as /compare-tool/ rather than the root domain, use the BASE_PATH environment variable to set it: BASE_PATH=/compare-tool/ yarn build
  2. Deploy public/ to a server.

Local config

The compare tool allows you to use a local config file (public/config/local.js) to customize for your use case.

Here, you can customize the following options:

For more details on how these should look, see the example in public/config/local.example.js.

Setting up the app in your repo

1. Install this module into your repo.

npm i github:stamen/maperture#<release> or yarn add github:stamen/maperture#<release>

2. Set up files to serve app

When setting up the app in your repo, you'll want to create a directory that can house:

Your index.html file should look like the following:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1" />

    <title>Maperture</title>

    <link rel="stylesheet" href="./dist/bundle.css" />
  </head>

  <script type="module">
    import { startApp } from './dist/bundle.js';
    import * as localConfig from './local.js';

    startApp(document.body, { localConfig });
  </script>

  <body></body>
</html>

3. In addition, prior to serving the compare tool in your repo, you'll want to add a simple build script to your package that will copy our module files into the appropriate directory where tool/dir/path/ is the directory you've created to serve the app from:

"build-compare": "rm -rf tool/dir/path/dist && cp -r node_modules/maperture/dist tool/dir/path/dist"

You will run this build script prior to serving the app from index.html or publishing the app anywhere to ensure files are up to date.

The final directory structure should look like:

root/
  - maperture/
    - dist/
      - bundle.js
      - bundle.js.map
      - bundle.css
    - index.html
    - local.js