2014-09-16 03:29:28 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Minetest demo map</title>
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
<link rel="stylesheet" href="css/leaflet.css" />
|
|
|
|
<link rel="stylesheet" href="css/Leaflet.Coordinates-0.1.4.css" />
|
2014-09-23 16:18:15 +02:00
|
|
|
<link rel="stylesheet" href="css/font-awesome.css" />
|
2014-09-16 03:29:28 +02:00
|
|
|
<style type="text/css">
|
|
|
|
body {
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
#map {
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
background-color: #111111;
|
|
|
|
}
|
|
|
|
|
|
|
|
.leaflet-container {
|
|
|
|
cursor: crosshair;
|
|
|
|
}
|
|
|
|
|
|
|
|
.leaflet-control-coordinates,
|
|
|
|
.leaflet-control-layers {
|
|
|
|
box-shadow: 0 1px 3px rgba(0,0,0,0.3);
|
|
|
|
background-color:rgba(255,255,255,.85);
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="map"></div>
|
|
|
|
<script src="js/leaflet.js"></script>
|
|
|
|
<script src="js/Leaflet.Coordinates-0.1.4.min.js"></script>
|
2014-09-23 16:18:15 +02:00
|
|
|
<script src="js/easy-button.js"></script>
|
2015-03-03 15:22:00 +01:00
|
|
|
<script src="js/auto-update.js"></script>
|
2015-03-01 17:32:46 +01:00
|
|
|
<script type="text/javascript" src="js/leaflet-hash.js"></script>
|
2014-09-16 03:29:28 +02:00
|
|
|
<script>
|
|
|
|
|
2014-09-23 16:18:15 +02:00
|
|
|
|
2014-09-16 03:29:28 +02:00
|
|
|
L.Projection.NoWrap = {
|
|
|
|
project: function (latlng) {
|
|
|
|
return new L.Point(latlng.lat, latlng.lng);
|
|
|
|
},
|
|
|
|
|
|
|
|
unproject: function (point, unbounded) {
|
|
|
|
return new L.LatLng(point.x, point.y, true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
L.CRS.Direct = L.Util.extend({}, L.CRS, {
|
|
|
|
code: 'Direct',
|
|
|
|
projection: L.Projection.NoWrap,
|
|
|
|
transformation: new L.Transformation(1.0/65536, 30928.0/65536, -1.0/65536, 34608.0/65536)
|
|
|
|
});
|
|
|
|
|
|
|
|
var world = new L.tileLayer('map/{z}/{x}/{y}.png', {
|
|
|
|
minZoom: 0,
|
|
|
|
maxZoom: 16,
|
|
|
|
attribution: 'Demo world',
|
|
|
|
continuousWorld: false,
|
|
|
|
noWrap: true,
|
2014-09-23 16:18:15 +02:00
|
|
|
tms: true,
|
|
|
|
unloadInvisibleTiles: true
|
2014-09-16 03:29:28 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
var rasterMaps = {
|
|
|
|
"A demo world": world,
|
|
|
|
};
|
|
|
|
|
|
|
|
var latest = world
|
|
|
|
|
|
|
|
var overlayMaps = {};
|
|
|
|
|
|
|
|
var map = L.map('map', {
|
|
|
|
center: [0,0],
|
|
|
|
zoom: 3,
|
|
|
|
layers: [latest],
|
|
|
|
worldCopyJump: false,
|
|
|
|
crs: L.CRS.Direct});
|
|
|
|
|
|
|
|
L.control.coordinates({
|
|
|
|
position:"topright", //optional default "bootomright"
|
|
|
|
decimals:0, //optional default 4
|
|
|
|
decimalSeperator:".", //optional default "."
|
|
|
|
labelTemplateLat:"X: {y}", //optional default "Lat: {y}"
|
|
|
|
labelTemplateLng:"Y: {x}", //optional default "Lng: {x}"
|
|
|
|
enableUserInput:false, //optional default true
|
|
|
|
useDMS:false, //optional default false
|
|
|
|
useLatLngOrder: true //ordering of labels, default false-> lng-lat
|
|
|
|
}).addTo(map);
|
|
|
|
|
2015-03-03 15:22:00 +01:00
|
|
|
var manualUpdateControl;
|
2015-03-04 10:36:59 +01:00
|
|
|
L.autoUpdate('autoUpdate', function(pressed) {
|
|
|
|
if (pressed) {
|
2015-03-03 15:22:00 +01:00
|
|
|
manualUpdateControl.getContainer().style = 'visibility: hidden';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
manualUpdateControl.getContainer().style = 'visibility: visible';
|
|
|
|
}
|
|
|
|
});
|
2014-09-16 03:29:28 +02:00
|
|
|
var layersControl = new L.Control.Layers(rasterMaps, overlayMaps, {collapsed: false});
|
|
|
|
map.addControl(layersControl);
|
|
|
|
|
2015-03-03 15:22:00 +01:00
|
|
|
manualUpdateControl = L.easyButton('fa-refresh',
|
2014-09-23 16:18:15 +02:00
|
|
|
function (){
|
|
|
|
var tiles = document.getElementsByTagName("img");
|
|
|
|
for (var i = 0; i < tiles.length; i++) {
|
|
|
|
var img = tiles[i];
|
|
|
|
var cl = img.getAttribute("class");
|
|
|
|
if (cl.contains("leaflet-tile-loaded")) {
|
|
|
|
var src = img.src;
|
|
|
|
var idx = src.lastIndexOf("#");
|
|
|
|
if (idx >= 0) {
|
|
|
|
src = src.substring(0, idx);
|
|
|
|
}
|
|
|
|
img.src = src + "#" + Math.random();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//map._resetView(map.getCenter(), map.getZoom(), false);
|
|
|
|
},
|
|
|
|
'Update view'
|
2015-03-03 15:22:00 +01:00
|
|
|
);
|
2015-03-01 17:32:46 +01:00
|
|
|
var hash = new L.Hash(map)
|
2014-09-16 03:29:28 +02:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|