Skip to content

Commit 981e842

Browse files
author
hezhentao
committed
# Conflicts: # website/public/static/demo/mapboxgl/example/datastore/elasticsearch/grid-search.htm # website/public/static/demo/mapboxgl/example/datastore/elasticsearch/heat-search.htm
2 parents 190da75 + 1703de6 commit 981e842

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2690
-15069
lines changed

src/cesiumjs/overlay/PopupLayer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ export default class PopupLayer {
7373
this.scene = map.scene;
7474
this.camera = map.camera;
7575
this.isShow = true;
76-
console.log('popup 1');
7776

78-
this.handler = new Cesium.ScreenSpaceEventHandler(this.scene.canvas);
77+
ScreenSpaceEventHandler = Cesium.ScreenSpaceEventHandler || window["Cesium"].ScreenSpaceEventHandler;
78+
79+
this.handler = new ScreenSpaceEventHandler(this.scene.canvas);
7980

8081
this.infoDiv = null;
8182
// this.px_position = null;
8283
if (position.entity) {
8384
this.cartesian = position.entity.position._value;
8485
}
85-
console.log('popup 2');
8686

8787
this.cartesian =
8888
this.cartesian ||

src/cesiumjs/render/VectorTileLayer.js

Lines changed: 82 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getLayers, getFonts, getVectorTileSource, getSpritePng } from './vector
44
import VectorTileProvider from './vectortile/VectorTileProvider';
55
import VectorTileStyle from './vectortile/MapgisVectorTileStyle';
66
import axios from 'axios';
7+
import { find } from 'ol/array';
78

89
/**
910
* @author 基础平台/创新中心 潘卓然 ParnDeedlit
@@ -58,15 +59,15 @@ export class VectorTileLayer {
5859
//this.bindEvent();
5960

6061
if (this.style) {
61-
if (this.style.indexOf('http') >= 0) {
62+
if (typeof this.style === 'string') {
6263
//如果是个网络地址,就通过url请求获取矢量瓦片json对象
6364
this.url = this.style;
6465
this.requestVectortileJson();
6566
} else {
66-
this.requestStyleData();
67+
this.requestStyleData(this.style);
6768
}
6869
} else if (this.styleUrl) {
69-
if (this.styleUrl.indexOf('http') >= 0) {
70+
if (typeof this.styleUrl === 'string') {
7071
this.url = this.styleUrl;
7172
this.requestVectortileJson();
7273
} else {
@@ -77,7 +78,7 @@ export class VectorTileLayer {
7778
//如果没有矢量瓦片json对象,就通过url请求获取矢量瓦片json对象
7879
this.requestVectortileJson();
7980
} else {
80-
this.requestStyleData();
81+
this.requestStyleData(this.vectortilejson);
8182
}
8283
}
8384
}
@@ -117,6 +118,7 @@ export class VectorTileLayer {
117118
* @see https://docs.mapbox.com/mapbox-gl-js/style-spec/
118119
*/
119120
requestStyleData(vectortilejson) {
121+
this.vectortilejson = vectortilejson;
120122
var layers = getLayers(vectortilejson);
121123
var sources = getVectorTileSource(vectortilejson);
122124
var spritepng = getSpritePng(vectortilejson);
@@ -173,45 +175,89 @@ export class VectorTileLayer {
173175
}
174176

175177
/**
176-
* 通过修改图层样式,更新图层
177-
* @function module:客户端渲染.VectorTileLayer.prototype.updateLayer
178-
* @param {Array} layersStyle 所有图层的样式参数 Array<Mapbox-Style-Spec-Layers>
178+
* @description 设置布局属性
179+
* @function module:客户端渲染.VectorTileLayer.prototype.updateStyle
180+
* @param {Object} mvtStyle
179181
*/
180-
updateLayer(layersStyle) {
181-
if (!this.styleData || !this.styleData.vectortilejson || !this.styleData.vectortilejson.layers) {
182-
return;
183-
}
182+
updateStyle(mvtStyle) {
183+
if (!this.styleData) return;
184+
this.styleData.vectortilejson = mvtStyle;
184185
this.remove();
185-
this.styleData.vectortilejson.layers = layersStyle;
186-
var layers = [];
187-
for (var i = 0; i < layersStyle.length; i++) {
188-
layers.push(layersStyle[i].id);
189-
}
190-
this.styleData.layers = layers;
191186
this.addLayer(this.styleData);
192187
}
193188

194189
/**
195-
* 获取所有图层的样式
196-
* @function module:客户端渲染.VectorTileLayer.prototype.getLayersStyle
197-
* @returns {*} 获取满足MVT样式的图层信息
190+
* @description 设置布局属性
191+
* @function module:客户端渲染.VectorTileLayer.prototype.setLayoutProperty
192+
* @param {String} layer
193+
* @param {String} key
194+
* @param {Object} value
198195
*/
199-
getLayersStyle() {
200-
if (!this.styleData || !this.styleData.vectortilejson || !this.styleData.vectortilejson.layers) {
201-
return;
202-
}
203-
return this.styleData.vectortilejson.layers;
196+
setLayoutProperty(layerId, key, value) {
197+
if (!this.vectortilejson || !this.vectortilejson.layers) return;
198+
const { layers } = this.vectortilejson;
199+
let finds = layers.filter((l) => {
200+
return l.id === layerId;
201+
});
202+
let layer = finds && finds.length > 0 ? finds[0] : undefined;
203+
if (!layer) return;
204+
layer.layout = layer.layout || {};
205+
layer.layout[key] = value;
206+
this.styleData.vectortilejson = this.vectortilejson;
207+
this.remove();
208+
this.addLayer(this.styleData);
209+
}
210+
211+
/**
212+
* @description 设置画笔属性
213+
* @function module:客户端渲染.VectorTileLayer.prototype.setPaintProperty
214+
* @param {String} layerId
215+
* @param {String} key
216+
* @param {Object} value
217+
*/
218+
setPaintProperty(layerId, key, value) {
219+
if (!this.vectortilejson || !this.vectortilejson.layers) return;
220+
const { layers } = this.vectortilejson;
221+
let finds = layers.filter((l) => {
222+
return l.id === layerId;
223+
});
224+
let layer = finds && finds.length > 0 ? finds[0] : undefined;
225+
if (!layer) return;
226+
layer.paint = layer.paint || {};
227+
layer.paint[key] = value;
228+
this.remove();
229+
this.addLayer(this.styleData);
230+
}
231+
232+
/**
233+
* @description 设置过滤属性
234+
* @function module:客户端渲染.VectorTileLayer.prototype.setFilter
235+
* @param {String} layerId
236+
* @param {Array} rule
237+
*/
238+
setFilter(layerId, rule) {
239+
if (!this.vectortilejson || !this.vectortilejson.layers) return;
240+
const { layers } = this.vectortilejson;
241+
let finds = layers.filter((l) => {
242+
return l.id === layerId;
243+
});
244+
let layer = finds && finds.length > 0 ? finds[0] : undefined;
245+
if (!layer) return;
246+
layer.filter = layer.filter || {};
247+
layer.filter = rule;
248+
this.remove();
249+
this.addLayer(this.styleData);
204250
}
205251

206-
unbindEvent() { }
252+
unbindEvent() {}
207253

208-
moveStartEvent() { }
254+
moveStartEvent() {}
209255

210-
moveEndEvent() { }
256+
moveEndEvent() {}
211257

212-
zoomStartEvent() { }
258+
zoomStartEvent() {}
213259

214-
zoomEndEvent() { }
260+
zoomEndEvent() {}
215261

216262
/**
217263
* 销毁图层-实际调用remove,为了接口保持一致
@@ -237,12 +283,17 @@ export class VectorTileLayer {
237283
*/
238284
remove() {
239285
let self = this;
286+
if (self.provider) {
287+
self.viewer.imageryLayers.remove(self.provider, true);
288+
self.provider.show = false;
289+
}
290+
/* let self = this;
240291
window.setTimeout(() => {
241292
if (self.provider) {
242293
self.viewer.imageryLayers.remove(self.provider, true);
243294
self.provider.show = false;
244295
}
245-
}, 1000);
296+
}, 1000); */
246297
}
247298
}
248299

src/service/ArcGis/BaseParam.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import {
2+
Zondy,cloneObject
3+
} from '../common';
4+
5+
/**
6+
* @class module:ArcGis.ArcGisBaseParam
7+
* @description ArcGis服务
8+
* @author 基础平台-杨琨
9+
*/
10+
class ArcGisBaseParam {
11+
clone(){
12+
//完全返回一个新对象
13+
return cloneObject(this);
14+
}
15+
16+
//接收一个参数对象,如果参数对象里的值,本身也含有,则赋值,否则不赋值
17+
static fromJSON(JSON){
18+
let me = new this();
19+
if(JSON instanceof Object){
20+
for(let key in JSON){
21+
if(me.hasOwnProperty(key)){
22+
me[key] = JSON[key];
23+
}
24+
}
25+
}
26+
return me;
27+
}
28+
29+
toJSON(){
30+
//按照arcgis的tiJson编写,因为只接受对象类型,因此不做其他类型判断,返回一个对象
31+
let objInn = this;
32+
let returnObj = {};
33+
for (let attr in objInn) {
34+
if (typeof objInn[attr] !== "function" && attr !== "CLASS_NAME") {
35+
if(objInn[attr]) returnObj[attr] = objInn[attr];
36+
}
37+
}
38+
returnObj["spatialRel"] = "esriSpatialRelIntersects";
39+
return returnObj;
40+
}
41+
}
42+
43+
export {ArcGisBaseParam};
44+
Zondy.Service.ArcGisBaseParam = ArcGisBaseParam;

0 commit comments

Comments
 (0)