Presentation slides on creating custom map tiles for bounded areas with Maperitive.
Size: 1.43 MB
Language: en
Added: Oct 23, 2013
Slides: 41 pages
Slide Content
MAPERITIVE
CREATING CUSTOM MAP TILES FOR
BOUNDED AREAS
by Calvin Ng / @calvinnwq
BACKGROUND
I've created an app which utilises
to retrieve real time tweets with geolocation and plot them
onto a map using .
Twitter's Streaming API
leaflet.js
...
Then came the requirement
...
CUSTOM DESIGNED MAP
WHAT NEXT?
Having no clue, I did what any of you would
...
GOOGLE
MAPERITIVE
This presentation will go through the solution I stuck with
after a couple others that I've tried
...
SO LET'S BEGIN!
1. MAPERITIVE
“Maperitive is a FREE desktop application for drawing maps
based on OpenStreetMap and GPS data. You can define what
gets on the map and how it is painted. You can also export
these maps into bitmaps and SVG files and print them.”
SYSTEM REQUIREMENTS
Windows: XP SP3 or later with installed.
Linux & Mac: latest installed.
Microsoft.NET 4
Mono
WHAT CAN I DO WITH MAPERITIVE?
Make maps with custom content and style
Render relief contours, hillshading,
Exporting maps to bitmaps or SVG files
Make map tiles for the web
Automating mapmaking through scripts, Python and
Maperitive command-line console
hypsometric tinting
MAPERITIVE LINKS
Download Link
Ten Minute Intro
Maperitive Documentation
2. STARTING UP MAPERITIVE
OPENING UP MAPERITIVE ON WINDOWS / MAC / LINUX
WINDOWS
Ensure XP SP3 or later with Microsoft.NET 4 installed and
simply run Maperitive.exe
MAC / LINUX
Ensure is installed and assuming Maperitive is
extracted to Desktop, run the following:
Mono
$ sh ~/Desktop/Maperitive/Maperitive.sh
SCREENSHOT
INTERFACE
3. GEO BOUNDING BOX
RETRIEVING GEO COORDINATES AND SETTING UP GEO BOUNDS
CONSIDERATIONS?
Are there any specific countries? (e.g. Singapore)
What are the zoom levels to consider?
Is the map fixed or interactive?
ONLINE TOOLS
1.
2. by
OpenStreetMap
Bounding BoxKlokan Technologies
BOUNDING BOX
Select an area and select "CSV" as type of data
4. EXPORTING BITMAP
EXPORTING PNG FOR CUSTOM DESIGNING
EXPORT BITMAP
2 files will be generated in output folder:
output.png
output.png.georef (required for later steps)
5. EDITING CUSTOM MAP
DESIGNING OF CUSTOM MAP AND CONSTRAINTS
CONSTRAINTS?
output.png should be the template to work upon.
Custom designed map (let's call it map.png) should retain
exact dimensions as output.png
Multiple layers to show terrain / roads / etc.?
SAMPLE CUSTOM MAP
For the sake of this presentation, here is a sample map I've
made which I will name map.png
6. LOADING CUSTOM MAP
LOAD CUSTOM EDITED MAP IN MAPERITIVE
CUSTOM MAP FILES
Using map.png from our previous example, we will also
need to create a copy of output.png.georef and rename that
to map.png.georef
LOAD IMAGE IN MAPERITIVE
Assuming we put map.png and map.png.georef back into the
output folder:
load-image file=output/map.png background=false
DISABLE OTHER MAPS
You can choose to disable underlying maps like the default
Web map (OSM Mapnik) so they don't get generated by
simply clicking on the yellow star under the Map Sources at
the bottom right
7. GENERATE TILES
GENERATING TILES FOR SPECIFIC ZOOM LEVELS
GENERATE TILES
For this example we will generate tiles for 2 zoom levels (11
& 12) for the bounding box we have.
generate-tiles minzoom=11 maxzoom=12 bounds=103.406067,1.090327,104.246521,1.607913
Generated tiles can be found in the Tiles folder
TILES FOLDER
8. MAP TILES
HOW TO USE THEM
HOSTING THEM
Copy the folders to your project directory. In the example to
follow, I've placed them in my assets folder of this
presentation with path assets/tiles/
REFERENCING THEM IN CODE
Referencing them is as simple as using the following URL:
var tile_url =
"http://calvinnwq.github.io/maperitive-presentation/assets/tiles/{z}/{x}/{y}.png";
EXAMPLE CODE
In this example, I will make use of .leaflet.js
// create bounds
var bounds = new L.LatLngBounds(
new L.LatLng(1.090327, 103.406067)
, new L.LatLng(1.607913, 104.246521)
);
// create a map in the "map" div, set the view to a given place and zoom
var map = L.map('map', {
"center" : [1.335, 103.820]
, "zoom" : 11
, "minZoom" : 11
, "maxZoom" : 12
, "maxBounds" : bounds
});
// add an OpenStreetMap tile layer
L.tileLayer('http://calvinnwq.github.io/maperitive-presentation/assets/tiles/{z}/{x}/{y}.png'
attribution: "Calvin's custom map design"
, minZoom: 11
, maxZoom: 12
}).addTo(map);
EXAMPLE RESULT
Run it!
SUMMARY
WHAT DID WE LEARN TODAY?
MAPERITIVE SUMMARY
What Maperitive is
Starting up Maperitive