-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
84 lines (72 loc) · 3.15 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html>
<head>
<title>gdal2tiles test</title>
<meta charset="utf-8">
<meta http-equiv="imagetoolbar" content="no"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<style type="text/css">
html, body { margin:0; padding:0; height: 100%; width: 100%; }
body { width:100%; height:100%; background: #ffffff; }
#map { position: absolute; height: 100%; width: 100%; background-color: #FFFFFF; }
</style>
<!--
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.3.1/css/ol.css" type="text/css">
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL,fetch,Function.prototype.bind,es5&flags=always,gated&unknown=polyfill" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.3.1/build/ol.js" type="text/javascript"></script>
-->
<link rel="stylesheet" href="https://cdn.maptiler.com/ol/v5.3.0/ol.css" type="text/css">
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL,fetch,Function.prototype.bind,es5&flags=always,gated&unknown=polyfill" type="text/javascript"></script>
<script src="https://cdn.maptiler.com/ol/v5.3.0/ol.js" type="text/javascript"></script>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">
var mapExtent = [0, -16384, 16384, 0];
var mapMinZoom = 0;
var mapMaxZoom = 7;
var mapMaxResolution = 0.5;
var tileExtent = [0, -16384, 16384, 0];
var mapResolutions = [];
for (var z = 0; z <= mapMaxZoom; z++) {
mapResolutions.push(Math.pow(2, mapMaxZoom - z) * mapMaxResolution);
}
var mapTileGrid = new ol.tilegrid.TileGrid({
extent: tileExtent,
minZoom: mapMinZoom,
resolutions: mapResolutions
});
var layer = new ol.layer.Tile({
source: new ol.source.XYZ({
attributions: 'gdal2tiles',
tileGrid: mapTileGrid,
tilePixelRatio: 2.00000000,
url: "imgs/{z}/{x}/{-y}.png",
})
});
ol.events.condition.customDragRotate = function(mapBrowserEvent) {
var browserEvent = mapBrowserEvent.originalEvent;
return (browserEvent.shiftKey);
};
var map = new ol.Map({
target: 'map',
layers: [ layer ],
interactions: ol.interaction.defaults().extend([
new ol.interaction.DragRotate({ condition: ol.events.condition.customDragRotate })
]),
view: new ol.View({
projection: ol.proj.get('PIXELS'),
extent: mapExtent,
maxResolution: mapTileGrid.getResolution(mapMinZoom)
})
});
map.getInteractions().getArray().forEach(function(interaction) {
if (interaction instanceof ol.interaction.DragZoom) {
map.removeInteraction(interaction);
}
});
map.getView().fit(mapExtent, map.getSize());
</script>
</body>
</html>