Skip to content

Commit dd216ec

Browse files
author
Peter Magnusson
committed
* minimal openlayers web interface for viewing maps
1 parent 57ca3c7 commit dd216ec

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

contrib/openlayers/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#OpenLayers + mcmap#
2+
This is a simple example of how you could start using mcmap with [OpenLayers](http://openlayers.org).
3+
OpenLayers makes it easy to put a dynamic map in any web page. It can display map tiles and markers loaded from any source.
4+
OpenLayers has been developed to further the use of geographic information of all kinds.
5+
OpenLayers is completely free, Open Source JavaScript, released under the 2-clause BSD License (also known as the FreeBSD).
6+
7+
8+
##Instructions##
9+
This will work on Linux if you have ImageMagic and pngcrush installed.
10+
11+
* Make sure mcmap is in your path or edit render.sh
12+
* $>./render.sh
13+
* open mcmap.html in a web browser.
14+
The browser must support loading from local files or you have to put mcmap.html and the tiles folder that will be crated on a web server
15+
16+
17+
18+
##TODO##
19+
* Make stuff use some sort of usable coordinate system and don't let openlayers guess it
20+

contrib/openlayers/mcmap.html

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<html>
2+
<head>
3+
<title>mcmap Sample</title>
4+
<script src="http://openlayers.org/api/OpenLayers.js"></script>
5+
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
6+
<script defer="defer" type="text/javascript">
7+
var map;
8+
9+
$(document).ready(function(){
10+
init();
11+
});
12+
13+
function init(){
14+
map = new OpenLayers.Map('map', {
15+
numZoomLevels:6,
16+
eventListeners: {
17+
"zoomend": mapEvent,
18+
"moveend": mapEvent
19+
}
20+
});
21+
var xyz = new OpenLayers.Layer.XYZ("mcmap Layer", "./tiles/x${x}y${y}z${z}.png");
22+
map.addLayer(xyz);
23+
map.zoomToMaxExtent();
24+
}
25+
26+
function mapEvent(event){
27+
$(".zoomLevel").html(map.getZoom());
28+
}
29+
</script>
30+
</head>
31+
<body>
32+
<p>Zoom:<span class="zoomLevel"></span></p>
33+
<div style="width:100%; height:100%; border:1px solid black;" id="map"></div>
34+
</body>
35+
</html>

contrib/openlayers/render.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
#first argument should be the world
4+
WORLD=$1
5+
# where can we find mcmap
6+
MCMAPBIN="mcmap"
7+
# where shoud we put the processed tiles
8+
TILESDIR="`pwd`/tiles"
9+
# where do we put the raw tiles
10+
RAWTILESDIR="`pwd`/tmp"
11+
12+
function usage(){
13+
echo "Usage:"
14+
echo $0 "<path to world>"
15+
}
16+
17+
if [[ ! -d $WORLD ]] ; then
18+
usage
19+
exit 1
20+
fi
21+
22+
#make some folders to store stuff
23+
if [[ ! -d $TILESDIR ]] ; then
24+
mkdir -p $TILESDIR
25+
fi
26+
if [[ ! -d $RAWTILESDIR ]] ; then
27+
mkdir -p $RAWTILESDIR
28+
fi
29+
30+
31+
#generate the raw tiles
32+
$MCMAPBIN -split $RAWTILESDIR $WORLD
33+
34+
#process all raw tiles
35+
echo "Processing raw tiles"
36+
for SRC in $RAWTILESDIR/*.png ; do
37+
FILE="`basename $SRC`"
38+
#default tile size for OpenLayers is 256x256 pixels
39+
convert -scale 256 $SRC $TILESDIR/$FILE
40+
done
41+
echo "Done"
42+

0 commit comments

Comments
 (0)