Skip to content

Commit 67120d0

Browse files
author
潘卓然Y7000P
committed
【SDK】【新增】【OpenLayers新增ShapeFile文件图层】
1 parent a53c046 commit 67120d0

4 files changed

Lines changed: 80 additions & 1 deletion

File tree

src/openlayers/layer/mapLayer.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ var MapLayerTileSource = function (opt_options) {
168168
*/
169169
//this.tileUrlFunction = options.tileUrlFunction !== undefined ? options.tileUrlFunction :this.tileUrlFunctionExtend;
170170

171+
/**
172+
* @type {string}
173+
* @description ShapeFile的服务器shp文件路径
174+
*/
175+
this.mapstyUri = options.mapstyUri;
176+
177+
/**
178+
* @type {Object}
179+
* @description ShapeFile的服务器样式文件xml路径
180+
*/
181+
this.mapstyOption = options.mapstyOption;
182+
171183
//this.url_ = "http://" + this.ip + ":" + this.port + "/igs/rest/mrms/layers";
172184
if (this.domain === '') {
173185
this.url_ = this.networkProtocol + "://" + this.ip + ":" + this.port + "/igs/rest/mrms/layers";
@@ -218,7 +230,9 @@ MapLayerTileSource.prototype.tileUrlFunctionExtend = function (tileCoord, pixelR
218230
var params = {
219231
'f': this.f,
220232
'rlt': this.rlt,
221-
'guid': this.guid
233+
'guid': this.guid,
234+
'mapstyUri': '',
235+
'mapstyOption': {}
222236
};
223237

224238
if (this.gdbps != null && this.gdbps != "") {
@@ -253,6 +267,8 @@ MapLayerTileSource.prototype.tileUrlFunctionExtend = function (tileCoord, pixelR
253267
params['w'] = this.tileSize;
254268
params['h'] = this.tileSize;
255269
params['bbox'] = bbox.join(',');
270+
params['mapstyUri'] = this.mapstyUri;
271+
params['mapstyOption'] = JSON.stringify(this.mapstyOption);
256272
return appendParams(this.url_, params);
257273
};
258274

website/public/static/demo/config/config-openlayers.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@
142142
"detail": "矢量图层",
143143
"icon": "gdbplayer.png",
144144
"update": "最后更新时间:2020-12-16"
145+
},
146+
{
147+
"name": "ShapeFile矢量图层",
148+
"file": "shapefilelayer",
149+
"diffcult": "4",
150+
"detail": "矢量图层",
151+
"icon": "shapefilelayer.png",
152+
"update": "最后更新时间:2020-12-16"
145153
}
146154
]
147155
},
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<title>矢量图层显示</title>
5+
<!--引入当前页面样式表-->
6+
<link href="./style.css" rel="stylesheet" type="text/css" />
7+
<script src="./static/libs/include-openlayers-local.js"></script>
8+
<script type="text/javascript">
9+
//定义地图文档图层和地图
10+
var VecLayer, map;
11+
12+
/** 初始化地图显示*/
13+
function init() {
14+
//图层显示名称
15+
var name = 'MapGIS IGS VecLayer';
16+
//要显示的图层的gdbps地址
17+
var gdbps = [
18+
'C:\\Users\\Administrator\\Documents\\WXWork\\1688852418315641\\Cache\\File\\2020-12\\公路通行圈\\bj_point_4h_1test_60.shp'
19+
];
20+
//创建一个图层
21+
VecLayer = new Zondy.Map.GdbpLayer(name, gdbps, {
22+
ip: '192.168.22.97',
23+
port: '6163', //访问IGServer的端口号,.net版为6163,Java版为8089,
24+
mapstyUri:
25+
'C:\\Users\\Administrator\\Documents\\WXWork\\1688852418315641\\Cache\\File\\2020-12\\公路通行圈\\公路通行圈样式.mapsty',
26+
mapstyOption: {
27+
DefaultShow: true,
28+
MapInfoShow: true,
29+
DynamicAnnShow: true,
30+
ThemeShow: true,
31+
SrsShow: true,
32+
SystemLibraryShow: true,
33+
LayerMappingType: 1
34+
}
35+
});
36+
console.log('VecLayer', VecLayer);
37+
//创建一个地图容器
38+
map = new ol.Map({
39+
//目标DIV
40+
target: 'mapCon',
41+
//添加图层到地图容器中
42+
layers: [VecLayer],
43+
view: new ol.View({
44+
center: [116.5, 39.75],
45+
zoom: 9,
46+
projection: 'EPSG:4326'
47+
})
48+
});
49+
}
50+
</script>
51+
</head>
52+
<body onload="init()">
53+
<div id="mapCon" style="width: 100%; height: 95%; position: absolute"></div>
54+
</body>
55+
</html>
19.1 KB
Loading

0 commit comments

Comments
 (0)