by Calvin Ng / @calvinnwq
I've created an app which utilises Twitter's Streaming API to retrieve real time tweets with geolocation and plot them onto a map using leaflet.js.
...
Then came the requirement
...
Having no clue, I did what any of you would
...
This presentation will go through the solution I stuck with after a couple others that I've tried
...
“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.”
Windows: XP SP3 or later with Microsoft.NET 4 installed. Linux & Mac: latest Mono installed.
Ensure XP SP3 or later with Microsoft.NET 4 installed and simply run Maperitive.exe
Ensure Mono is installed and assuming Maperitive is extracted to Desktop, run the following:
$ sh ~/Desktop/Maperitive/Maperitive.sh
Select an area and select "CSV" as type of data
set-geo-bounds 103.406067,1.090327,104.246521,1.607913
zoom-bounds
export-bitmap zoom=12
2 files will be generated in output folder:
For the sake of this presentation, here is a sample map I've made which I will name map.png
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
Assuming we put map.png and map.png.georef back into the output folder:
load-image file=output/map.png background=false
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
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
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 is as simple as using the following URL:
var tile_url =
"http://calvinnwq.github.io/maperitive-presentation/assets/tiles/{z}/{x}/{y}.png";
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);
Thank you for your attention