Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Created December 9, 2013 16:35
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save springmeyer/7875415 to your computer and use it in GitHub Desktop.
Save springmeyer/7875415 to your computer and use it in GitHub Desktop.
Example of simple scripting of TileMill exports - more details at https://www.mapbox.com/tilemill/docs/manual/exporting/#exports_from_the_command_line
#!/bin/bash
# Settings: edit these as needed
PROJECT_NAME="test"
OUTPUT_DIRECTORY="~/Documents/MapBox/export/"
# first change into TileMill code directory
cd /Applications/TileMill.app/Contents/Resources/
# hint: use http://bboxfinder.com/ to get bounds in lon/lat
# first export
BOUNDS="-125.090332,45.336702,-116.147461,49.253465"
NAME="washington"
echo "Exporting $NAME using $BOUNDS to ${OUTPUT_DIRECTORY}/${NAME}.mbtiles"
./index.js export ${PROJECT_NAME} ${OUTPUT_DIRECTORY}/${NAME}.mbtiles --minzoom=0 --maxzoom=4 --bbox=${BOUNDS}
# second export
BOUNDS="-125.551758,41.672912,-116.147461,49.253465"
NAME="oregon"
echo "Exporting $NAME using $BOUNDS to ${OUTPUT_DIRECTORY}/${NAME}.mbtiles"
./index.js export ${PROJECT_NAME} ${OUTPUT_DIRECTORY}/${NAME}.mbtiles --minzoom=0 --maxzoom=4 --bbox=${BOUNDS}
@springmeyer
Copy link
Author

To use this first download the raw script:

curl -O https://gist.github.com/springmeyer/7875415/raw/eeec55df00837da9e4af62d91c540d847f4fcf7d/tilemill-scripted-export.sh

Then make the script executable:

chmod +x tilemill-scripted-export.sh

Finally edit the settings at the top of the script and then run it:

./tilemill-scripted-export.sh

@geografa
Copy link

Export names should not have spaces in them.

@lonnieljyu
Copy link

Can you give an example of uploading the .mbtiles to your mapbox account using export's upload or sync format?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment