forked from lzugis/openlayers3-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vectortiles.html
67 lines (64 loc) · 2.04 KB
/
vectortiles.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="{{ asset('/css/main.css') }}">
<link rel="stylesheet" href="{{ asset('/css/ol.css') }}">
</head>
<body>
<div id="map" class="map fullsize"></div>
<script src="https://openlayers.org/en/v4.0.1/build/ol.js" charset="utf-8"></script>
<script type="text/javascript">
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile ({
source: new ol.source.OSM()
})
],
view: new ol.View({
center: ol.proj.transform([116.5, 39.9], 'EPSG:4326', 'EPSG:3857'),
zoom: 9
})
});
// 行政区划图层
var vectortileAdminLayer = new ol.layer.VectorTile({
source: new ol.source.VectorTile({
format: new ol.format.MVT(),
tileGrid: ol.tilegrid.createXYZ({maxZoom: 22}),
tilePixelRatio: 1,
url: 'http://127.0.0.1:8080/geoserver/gwc/service/tms/1.0.0/' +
'china:beijing_china_osm_admin_3857@EPSG%3A900913@pbf/{z}/{x}/{-y}.pbf'
}),
style: new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgb(140,137,129)'
}),
stroke: new ol.style.Stroke({
color: 'rgb(220, 220, 220)',
width: 1
})
})
});
map.addLayer(vectortileAdminLayer);
// 河流图层
var vectortileLayer = new ol.layer.VectorTile({
source: new ol.source.VectorTile({
format: new ol.format.MVT(),
tileGrid: ol.tilegrid.createXYZ({maxZoom: 22}),
tilePixelRatio: 1,
url: 'http://127.0.0.1:8080/geoserver/gwc/service/tms/1.0.0/' +
'china:beijing_china_osm_waterways_3857@EPSG%3A900913@pbf/{z}/{x}/{-y}.pbf'
}),
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'rgb(163,204,25)',
width: 5
})
})
});
map.addLayer(vectortileLayer);
</script>
</body>
</html>