maperitive

41
MAPERITIVE CREATING CUSTOM MAP TILES FOR BOUNDED AREAS by Calvin Ng / @calvinnwq

Upload: calvin-ng

Post on 21-Dec-2014

442 views

Category:

Technology


0 download

DESCRIPTION

Presentation slides on creating custom map tiles for bounded areas with Maperitive.

TRANSCRIPT

Page 1: Maperitive

MAPERITIVECREATING CUSTOM MAP TILES FOR

BOUNDED AREASby Calvin Ng / @calvinnwq

Page 2: Maperitive

BACKGROUNDI'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

Page 3: Maperitive

WHAT NEXT?Having no clue, I did what any of you would

...

GOOGLE

Page 4: Maperitive

MAPERITIVEThis presentation will go through the solution I stuck with

after a couple others that I've tried

...

SO LET'S BEGIN!

Page 5: Maperitive

1. MAPERITIVE“Maperitive is a FREE desktop application for drawing maps

based on OpenStreetMap and GPS data. You can define whatgets on the map and how it is painted. You can also export

these maps into bitmaps and SVG files and print them.”

Page 6: Maperitive

SYSTEM REQUIREMENTSWindows: XP SP3 or later with installed.

Linux & Mac: latest installed.Microsoft.NET 4Mono

Page 7: Maperitive

WHAT CAN I DO WITH MAPERITIVE?Make maps with custom content and styleRender relief contours, hillshading, Exporting maps to bitmaps or SVG filesMake map tiles for the webAutomating mapmaking through scripts, Python andMaperitive command-line console

hypsometric tinting

Page 9: Maperitive

2. STARTING UP MAPERITIVEOPENING UP MAPERITIVE ON WINDOWS / MAC / LINUX

Page 10: Maperitive

WINDOWSEnsure XP SP3 or later with Microsoft.NET 4 installed and

simply run Maperitive.exe

Page 11: Maperitive

MAC / LINUXEnsure is installed and assuming Maperitive is

extracted to Desktop, run the following:Mono

$ sh ~/Desktop/Maperitive/Maperitive.sh

Page 14: Maperitive

3. GEO BOUNDING BOXRETRIEVING GEO COORDINATES AND SETTING UP GEO BOUNDS

Page 15: Maperitive

CONSIDERATIONS?Are there any specific countries? (e.g. Singapore)What are the zoom levels to consider?Is the map fixed or interactive?

Page 16: Maperitive

ONLINE TOOLS1. 2. by

OpenStreetMapBounding Box Klokan Technologies

Page 17: Maperitive

BOUNDING BOXSelect an area and select "CSV" as type of data

Page 18: Maperitive

4. EXPORTING BITMAPEXPORTING PNG FOR CUSTOM DESIGNING

Page 19: Maperitive

SETTING BOUNDING BOXset-geo-bounds 103.406067,1.090327,104.246521,1.607913

Page 22: Maperitive

EXPORT BITMAP2 files will be generated in output folder:

output.pngoutput.png.georef (required for later steps)

Page 23: Maperitive

5. EDITING CUSTOM MAPDESIGNING OF CUSTOM MAP AND CONSTRAINTS

Page 24: Maperitive

CONSTRAINTS?output.png should be the template to work upon.Custom designed map (let's call it map.png) should retainexact dimensions as output.pngMultiple layers to show terrain / roads / etc.?

Page 25: Maperitive

SAMPLE CUSTOM MAPFor the sake of this presentation, here is a sample map I've

made which I will name map.png

Page 26: Maperitive

6. LOADING CUSTOM MAPLOAD CUSTOM EDITED MAP IN MAPERITIVE

Page 27: Maperitive

CUSTOM MAP FILESUsing map.png from our previous example, we will also

need to create a copy of output.png.georef and rename thatto map.png.georef

Page 28: Maperitive

LOAD IMAGE IN MAPERITIVEAssuming we put map.png and map.png.georef back into the

output folder:load-image file=output/map.png background=false

Page 29: Maperitive

DISABLE OTHER MAPSYou can choose to disable underlying maps like the default

Web map (OSM Mapnik) so they don't get generated bysimply clicking on the yellow star under the Map Sources at

the bottom right

Page 30: Maperitive

7. GENERATE TILESGENERATING TILES FOR SPECIFIC ZOOM LEVELS

Page 31: Maperitive

GENERATE TILESFor 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

Page 33: Maperitive

8. MAP TILESHOW TO USE THEM

Page 34: Maperitive

HOSTING THEMCopy the folders to your project directory. In the example to

follow, I've placed them in my assets folder of thispresentation with path assets/tiles/

Page 35: Maperitive

REFERENCING THEM IN CODEReferencing them is as simple as using the following URL:

var tile_url ="http://calvinnwq.github.io/maperitive-presentation/assets/tiles/{z}/{x}/{y}.png";

Page 36: Maperitive

EXAMPLE CODEIn this example, I will make use of .leaflet.js

// create boundsvar 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 zoomvar map = L.map('map', { "center" : [1.335, 103.820], "zoom" : 11, "minZoom" : 11, "maxZoom" : 12, "maxBounds" : bounds});

// add an OpenStreetMap tile layerL.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);

Page 37: Maperitive

EXAMPLE RESULTRun it!

Page 38: Maperitive

SUMMARYWHAT DID WE LEARN TODAY?

Page 39: Maperitive

MAPERITIVE SUMMARYWhat Maperitive isStarting up Maperitive

Page 40: Maperitive

STEPS SUMMARY1. 2. 3. 4. 5.

Obtaining geo bounding boxExporting bitmapEditing custom mapsLoading custom maps in MaperitiveGenerating map tiles

Page 41: Maperitive

FIN ~Thank you for your attention