egovamap 0.16.8 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -563,6 +563,8 @@ var egovaBI = function(globeMap, gisMap, mapType){
563
563
  originalData: true
564
564
  }
565
565
  }
566
+ //二维地图不获取原始数据
567
+ if(!globeMap) queryParam.options.originalData = false;
566
568
  let queryCallback = function (featureInfos) {
567
569
  execOperation(featureInfos);
568
570
  }
@@ -766,7 +768,7 @@ var egovaBI = function(globeMap, gisMap, mapType){
766
768
  options.layerName, // id,如果已经有attributes就没用了
767
769
  options.style, // style
768
770
  options.highlightStyle, // highlightStyle
769
- true, // zoom
771
+ options.commonSetting.zoom, // zoom
770
772
  options.keyFieldName,
771
773
  options.labelSetting.showLabel && options.labelFieldName, // keyField, labelField
772
774
  options.labelStyle, // labelStyle
@@ -877,24 +879,53 @@ var egovaBI = function(globeMap, gisMap, mapType){
877
879
  }
878
880
  // 执行绘制
879
881
  let drawLine = (options, data) => {
880
- if(!globeMap) {return}
881
- globeMap.lineOperation(options, data)
882
+ if (globeMap) globeMap.lineOperation(options, data);
883
+ else if (gisMap) {
884
+ let style = options.style || {};
885
+ let hStyle = options.hStyle || {};
886
+ let symbol = {
887
+ type: "simple-line", // autocasts as new SimpleLineSymbol()
888
+ color: style.color || "lightblue",
889
+ width: (style.width || 2) + "px",
890
+ style: style.style || "short-dot"
891
+ };
892
+ let hsymbol = {
893
+ type: "simple-line", // autocasts as new SimpleLineSymbol()
894
+ color: hStyle.color || "lightblue",
895
+ width: (hStyle.width || 2) + "px",
896
+ style: hStyle.style || "short-dot"
897
+ };
898
+ var opt = options.options || {};
899
+ gisMap.locateFeatureByCoords(data, options.type, options.id, symbol, hsymbol, options.zoom, options.keyField,
900
+ options.labelField,
901
+ options.labelStyle,
902
+ options.randomColor,
903
+ options.renderCanvas,
904
+ options.singleSelected,
905
+ opt,
906
+ options.layerTag,
907
+ options.callback
908
+ );
909
+ }
882
910
  }
883
911
 
884
912
  // 主逻辑
885
- if(!!data) {
913
+ if(!!data&&data.length) {
886
914
  drawLine(options, data)
887
915
  } else {
888
916
  if(!options.usageID) {
889
917
  console.log('图层用途必须传递')
890
918
  return
891
919
  }
920
+
921
+ let originalData = false;
922
+ if (globeMap) originalData = true;
892
923
  let queryParams = {
893
924
  layerID: options.usageID,
894
925
  where: options.filterString || "1=1",
895
926
  geometry: '',
896
927
  outGeometry: true,
897
- options: { originalData: true }
928
+ options: { originalData: originalData }
898
929
  }
899
930
  queryFeature(queryParams)
900
931
  .then(function(resultData) {
@@ -1829,6 +1829,10 @@ var EGovaGISMap = function ($container, pScene, prefix, gisParams, mapConfig, co
1829
1829
  that.callMap('getLayersByLayerGroup', layerGroupName, callback);
1830
1830
  }
1831
1831
 
1832
+ that.stopDraw = function(){
1833
+ that.callMap('stopDraw');
1834
+ }
1835
+
1832
1836
 
1833
1837
  that.init();
1834
1838
  }
@@ -1,6 +1,8 @@
1
1
  import EGovaGlobeMap from './egovaglobe';
2
2
  import EGovaGISMap from './egovagis';
3
3
  import EGovaGISViewer from './egovagisviewer';
4
+ import EGovaMobileMap from './egovamobile';
5
+ import EgovamapMEx from './egovamapMEx';
4
6
  import EGovaBI from './egovaBI';
5
7
  import MapSwich from './mapswich';
6
8
  import EGovaScene from './EGovaScene';
@@ -56,6 +58,7 @@ var EGovaMap = function (containerID, callback, mapConfig, mapType, mapParam, co
56
58
  var that = this;
57
59
  var globeMap = null;
58
60
  var gisMap = null;
61
+ var gisMobileMap = null;
59
62
  var mapSwich = null;
60
63
  var $mapsContainer = null;
61
64
  var parentScene = "parentScene";
@@ -125,7 +128,15 @@ var EGovaMap = function (containerID, callback, mapConfig, mapType, mapParam, co
125
128
  gisMap = new EGovaGISMap($mapsContainer, scene, msgPrefix + "_gis", mapParam, mapConfig, context);
126
129
  }
127
130
 
131
+ if(context.gisMobileEnabled == true || context.gisMobileEnabled == "1"){
132
+ gisMobileMap = new EGovaMobileMap($mapsContainer, scene, msgPrefix + "_gis", mapParam, mapConfig, context, callback)
133
+ }
134
+
128
135
  mapType = mapType || 'map';
136
+ if(mapType === "mapMobile" && gisMobileMap){
137
+ gisMobileMap.openMap();
138
+ }
139
+
129
140
  if (mapType == 'globe' && gisMap == null) {
130
141
  // 监听地图加载完成的事件
131
142
  globeMap.bindEvent("globeLoadedCallback", function () {
@@ -4221,6 +4232,7 @@ var EGovaMap = function (containerID, callback, mapConfig, mapType, mapParam, co
4221
4232
 
4222
4233
  // EGovaBI(globeMap).bind(this)();
4223
4234
  EGovaBI.call(this, globeMap, gisMap, mapType);
4235
+ gisMobileMap && EgovamapMEx.call(this, gisMobileMap);
4224
4236
  }
4225
4237
 
4226
4238
  var EGovaMapUtils = {
@@ -0,0 +1,15 @@
1
+ //移动端方法集成扩展
2
+ var egovamapMEx = function(gisMobileMap){
3
+
4
+ //常规写法,特殊处理的中间层则类似pc端手动添加
5
+ var methodEx = ['animateMap','locateFeatureByCoords', 'clearGraphic', 'setGraphicStyle', 'removeMapLayer', 'drawGeometry', 'showRoute', 'clearSelectFeature', 'showWFSLayer', 'showWMSLayer', 'showGridVectorLayer', 'switchBaseLayer', 'clearControl', 'pointSelect', 'queryFeature', 'addPopup', 'setOverlaysVisible', 'removePopup', 'getMapCenter', 'getMapExtent', 'getFullExtent', 'measureArea', 'measureLength', 'clearMap', 'zoomIn', 'zoomOut', 'zoomToExtent', 'zoomToCenter', 'fullExtent', 'getUsageKeyField', 'getPartKeyField', 'buffer', 'setControlOption', 'getAddressList', 'getAddressByXY', 'convertCoords', 'getCenterPoints', 'registerGlobleEvent', 'removeGlobleEvent', 'getExtentByGeoms', 'addMaskLayer', 'getLayerGroupConfig', 'initVectorTile', 'mapDraw', 'setMapDrag', 'setLayerProperty'];
6
+ //业务接口
7
+ var methodBusEx = ['markMap','getCellFieldByXY','getPhyFieldByXY','showMultiObjectCurrentPosition','highLightMultiObjectCurrentPosition','showMultiObjectCurrentPositionCluster','highLightMultiObjectCurrentPositionCluster', 'addHeatMap', 'showGeoLocation', 'showTraceHisLayer', 'clearTraceHisLayer', 'showTraceMultiHisLayer','setTraceMultiState', 'getTraceMultiState', 'traceMultiSelectbyID', 'multiPointsSelectbyID', 'setTraceMultiOptions', 'updateTraceMultiPosition', 'showTraceHisData', 'setTraceState', 'getTraceState', 'setTraceOptions', 'updateTracePosition', 'showTraceSingleLayer', 'traceSingleAppendData', 'hideTraceSingle','setMultiPatrolDynamicPositionOption','showMultiPatrolDynamicPosition','startRealtimeTrace','stopRealtimeTrace','realtimeRrace','stopRealtime','removeRealtimeLayer','getTraceDataInteval', 'queryObjectInfo', 'queryPhylayerFields', 'addControl', 'addMapvLayer', 'removeMapvLayer']
8
+ methodEx = methodEx.concat(methodBusEx);
9
+ for (let index = 0; index < methodEx.length; index++) {
10
+ var funcName = methodEx[index];
11
+ this[funcName] = gisMobileMap[funcName];
12
+ }
13
+ }
14
+
15
+ export default egovamapMEx
@@ -0,0 +1,299 @@
1
+ import MapUtils from './mapUtils';
2
+
3
+ var scene = null;
4
+ var _egovagismobileUrl = "";
5
+ function getCookie(name) {
6
+ var strCookie = window.document.cookie;
7
+ var arrCookie = strCookie.split("; ");
8
+ for (var i = 0; i < arrCookie.length; i++) {
9
+ var arr = arrCookie[i].split("=");
10
+ if (arr[0] == name)
11
+ return arr[1];
12
+ }
13
+ return null;
14
+ };
15
+ function setCookie(name, value) {
16
+ window.document.cookie = name + "=" + value;
17
+ }
18
+
19
+ function checkGisServerURL(url, callback) {
20
+ if(!url) return;
21
+
22
+ var cookieUrl = getCookie("gisUrl");
23
+ var gisProxyList = url.split(";");
24
+ cookieUrl && gisProxyList.push(cookieUrl);
25
+ if (gisProxyList.length <= 1) {
26
+ if (url.indexOf("http") != 0) {
27
+ url = window.location.origin + url;
28
+ }
29
+ callback(url);
30
+ return;
31
+ }
32
+ var params = {
33
+ isLoad: false
34
+ };
35
+ for (var i in gisProxyList) {
36
+ if (gisProxyList.hasOwnProperty(i)) {
37
+ if (gisProxyList[i].indexOf("http") != 0) {
38
+ gisProxyList[i] = window.location.origin + url;
39
+ }
40
+ checkGISProxy(gisProxyList[i], params, callback);
41
+ }
42
+ }
43
+ }
44
+
45
+ function trimEnd(str, c) {
46
+ var rg = new RegExp(c);
47
+ var i = str.length;
48
+ while (rg.test(str.charAt(--i)));
49
+ return str.slice(0, i + 1);
50
+ }
51
+
52
+ function checkGISProxy(proxyUrl, params, callback) {
53
+ var img = new Image();
54
+ if (proxyUrl.indexOf("http") != 0) {
55
+ proxyUrl = window.location.origin + "/" + proxyUrl;
56
+ }
57
+ img.src = trimEnd(proxyUrl, "/") + '/symbol/default.png';
58
+ img.onload = function (e1) {
59
+ if (!params.isLoad) {
60
+ params.isLoad = true;
61
+ setCookie("gisUrl", proxyUrl);
62
+ callback(proxyUrl);
63
+ }
64
+ img = null;
65
+ };
66
+ }
67
+
68
+ function getLocalStorageItem(name) {
69
+ if (localStorage) {
70
+ return localStorage.getItem(name);
71
+ } else {
72
+ return null;
73
+ }
74
+ }
75
+
76
+ var EGovaMobileMap = function ($container, pScene, prefix, gisParams, mapConfig, context, callback) {
77
+ var that = this;
78
+ scene = pScene;
79
+ var parentScene = pScene.pageId || "parentScene";
80
+ var msgPrefix = prefix || "mobilemappage";
81
+ that.gisVisible = false;
82
+ that.gisLoaded = false;
83
+ that.isLoading = false;
84
+
85
+ //that.$gisMapFrame = null;
86
+ that.gisMapContainer = null;
87
+ that.globeMapContainer = null;
88
+ that.useMask = false;
89
+ // if (context.mapCenterFlag == '2' && context.humanLayerUsageID && context.regionCode) {
90
+ // that.useMask = true;
91
+ // }
92
+
93
+ that.id = msgPrefix ? msgPrefix + "_emap" : 'emap';
94
+ that.gisDebug = (getLocalStorageItem('gisDebug')=='true');
95
+ that.gisMapContainer = document.getElementById(that.id);
96
+ if (!that.gisMapContainer) {
97
+ var emapContainer = $container.getElementsByClassName('emap-container')[0];
98
+ emapContainer && (emapContainer.style.display = 'none');
99
+
100
+ var emapIframe = $container.getElementsByClassName('emap-iframe')[0];
101
+ emapIframe && (emapIframe.style.display = 'none');
102
+
103
+ var element = document.createElement("div");
104
+ element.classList.add(that.id);
105
+ element.id = that.id;
106
+ $container.append(element);
107
+ that.gisMapContainer = element;
108
+ }
109
+
110
+ that.onMapLoaded = function () {
111
+ that.isLoading = false;
112
+ that.gisLoaded = true;
113
+ if (context.mapCenterFlag) {
114
+ if (context.mapCenterFlag == '1') {
115
+ if (context.coordinateX && context.coordinateY) {
116
+ that.zoomToCenter(context.coordinateX, context.coordinateY, 4);
117
+ }
118
+ } else if (context.mapCenterFlag == '2') {
119
+ //H5端遮罩未实现
120
+ } else if (context.mapCenterFlag == '3') {
121
+ //H5端遮罩未实现
122
+ }
123
+ }
124
+ callback && callback();
125
+ }
126
+
127
+ that.init = function () {
128
+ if (!that.gisLoaded && !that.isLoading) {
129
+ that.isLoading = true;
130
+ checkGisServerURL(context.gisServerURL, function (gisurl) {
131
+ var gisServerURL = context.gisServerURL = gisurl;
132
+ that.loadGISLibrary(gisServerURL);
133
+ });
134
+ }
135
+ }
136
+ /**
137
+ * 地图显示
138
+ *
139
+ * @param res
140
+ */
141
+ that.openMap = function (evt) {
142
+ if (!that.gisVisible) { // 初次定位时调整布局
143
+ if (!that.gisLoaded && !that.isLoading) {
144
+ that.isLoading = true;
145
+ }
146
+ if (that.gisMapContainer) {
147
+ that.gisMapContainer.style.display = 'block';
148
+ that.gisMapContainer.style.height = '100%';
149
+ }
150
+ that.gisVisible = true;
151
+ }
152
+ }
153
+
154
+ /**
155
+ * 二维地图关闭
156
+ */
157
+ that.closeMap = function (evt) {
158
+ if (that.gisMapContainer) {
159
+ that.gisMapContainer.style.display = 'none';
160
+ }
161
+ that.gisVisible = false;
162
+ }
163
+
164
+ that.loadGISLibrary = function (gisServerURL) {
165
+ var t = (new Date()).getTime();
166
+ if(gisServerURL !== _egovagismobileUrl && _egovagismobileUrl){
167
+ //如果第二次的GIS地址与上次不一致则删除上一次的,不考虑同一页面多个地图,地图GIS地址不一致的情况。(页面中始终只存在一个引用egovagis.js)
168
+ var curScript = document.querySelector('script[egovagismobile="' + _egovagismobileUrl +'"]');
169
+ var curLink = document.querySelector('link[egovagismobile="' + _egovagismobileUrl +'"]');
170
+ if(curScript && curLink) {
171
+ curScript.remove();
172
+ curLink.remove();
173
+ }
174
+ }
175
+ if(gisServerURL === _egovagismobileUrl){
176
+ that.createMap();
177
+ return;
178
+ };
179
+ _egovagismobileUrl = gisServerURL;
180
+ // 如果是ie,加上polyfill
181
+ if (document.documentMode) {
182
+ var polyfill = document.createElement("script");
183
+ polyfill.setAttribute("type", "text/javascript");
184
+ polyfill.setAttribute("src", root + '/library/egovagismobile/build/dist/polyfill.js');
185
+ document.body.appendChild(polyfill);
186
+ }
187
+ var mainScript = document.createElement('script');
188
+ mainScript.setAttribute('type', 'text/javascript');
189
+ var distOrSource = that.gisDebug ? 'source' : 'dist';
190
+ var url = gisServerURL + '/library/egovagismobile/build/' + distOrSource + '/egovagis.js?t=' + t;
191
+ var t = (new Date()).getTime();
192
+ var mainScript = document.createElement('script');
193
+ mainScript.setAttribute('egovagismobile', gisServerURL);
194
+ mainScript.setAttribute('type', 'text/javascript');
195
+ mainScript.setAttribute('src', url);
196
+ mainScript.onload = that.createMap.bind(that);
197
+ document.getElementsByTagName('head').item(0).appendChild(mainScript);
198
+ }
199
+
200
+ that.createMap = function(){
201
+ var params = {
202
+ contain: that.id,
203
+ serverURL: context.gisServerURL,
204
+ enableScaleline: context.enableScaleline,
205
+ debugTile: context.debugTile,
206
+ useCache: context.useCache,
207
+ humanID: context.humanID,
208
+ configName: mapConfig.config,
209
+ useMask: mapConfig.useMask,
210
+ token: context.token
211
+ }
212
+ if (!window.eMapList) {
213
+ window.eMapList = {};
214
+ }
215
+ window.eMapList[that.id] = new eMap(
216
+ params,
217
+ that.onMapLoaded.bind(that));
218
+ }
219
+
220
+ that.callMap = function () {
221
+ if (!window.eMapList) return;
222
+
223
+ var funcName = arguments[0],
224
+ eMap = window.eMapList[that.id];
225
+ if (eMap && eMap[funcName]) {
226
+ var args = [];
227
+ var curArgs = arguments[1];
228
+ for (var i = 0, ilen = curArgs.length; i < ilen; i++) {
229
+ if (context[curArgs[i]]) {
230
+ args.push(proxy(context[curArgs[i]], context));
231
+ } else if (typeof curArgs[i] == 'string') {
232
+ args.push(convertJSON(curArgs[i]))
233
+ } else {
234
+ args.push(curArgs[i]);
235
+ }
236
+ }
237
+ that.gisDebug && console.log(funcName);
238
+ return eMap[funcName].apply(eMap, args);
239
+ }
240
+ }
241
+
242
+ function convertJSON(str) {
243
+ if (typeof str == 'string') {
244
+ try {
245
+ var obj = JSON.parse(str);
246
+ if (typeof obj == 'object' && obj) {
247
+ if (Object.prototype.toString.call(obj) === '[object Object]')
248
+ obj = convertStyle(obj);
249
+ return obj;
250
+ } else {
251
+ return str;
252
+ }
253
+
254
+ } catch (e) {
255
+ return str;
256
+ }
257
+ }
258
+ }
259
+
260
+ function proxy(func, context) {
261
+ return function () {
262
+ var args = [];
263
+ for (var i = 0; i < arguments.length; i++) {
264
+ var arg = arguments[i];
265
+ var type = Array.isArray(arg) ? 'array' : (typeof arg);
266
+ if (arg && (type == 'object' || type == 'array')) {
267
+ args.push(JSON.stringify(arg));
268
+ } else {
269
+ args.push(arg);
270
+ }
271
+ }
272
+ var retVal = func.apply(context, args);
273
+ if (typeof retVal == 'string') {
274
+ retVal = convertJSON(retVal);
275
+ }
276
+ return retVal;
277
+ }
278
+ }
279
+
280
+
281
+ //方法挂载
282
+ //地图接口
283
+ var methodEx = ['animateMap','locateFeatureByCoords', 'clearGraphic', 'setGraphicStyle', 'removeMapLayer', 'drawGeometry', 'showRoute', 'clearSelectFeature', 'showWFSLayer', 'showWMSLayer', 'showGridVectorLayer', 'switchBaseLayer', 'clearControl', 'pointSelect', 'queryFeature', 'addPopup', 'setOverlaysVisible', 'removePopup', 'getMapCenter', 'getMapExtent', 'getFullExtent', 'measureArea', 'measureLength', 'clearMap', 'zoomIn', 'zoomOut', 'zoomToExtent', 'zoomToCenter', 'fullExtent', 'getUsageKeyField', 'getPartKeyField', 'buffer', 'setControlOption', 'getAddressList', 'getAddressByXY', 'convertCoords', 'getCenterPoints', 'registerGlobleEvent', 'removeGlobleEvent', 'getExtentByGeoms', 'addMaskLayer', 'getLayerGroupConfig', 'initVectorTile', 'mapDraw', 'setMapDrag', 'setLayerProperty'];
284
+ //业务接口
285
+ var methodBusEx = ['markMap','getCellFieldByXY','getPhyFieldByXY','showMultiObjectCurrentPosition','highLightMultiObjectCurrentPosition','showMultiObjectCurrentPositionCluster','highLightMultiObjectCurrentPositionCluster', 'addHeatMap', 'showGeoLocation', 'showTraceHisLayer', 'clearTraceHisLayer', 'showTraceMultiHisLayer','setTraceMultiState', 'getTraceMultiState', 'traceMultiSelectbyID', 'multiPointsSelectbyID', 'setTraceMultiOptions', 'updateTraceMultiPosition', 'showTraceHisData', 'setTraceState', 'getTraceState', 'setTraceOptions', 'updateTracePosition', 'showTraceSingleLayer', 'traceSingleAppendData', 'hideTraceSingle','setMultiPatrolDynamicPositionOption','showMultiPatrolDynamicPosition','startRealtimeTrace','stopRealtimeTrace','realtimeRrace','stopRealtime','removeRealtimeLayer','getTraceDataInteval', 'queryObjectInfo', 'queryPhylayerFields', 'addControl', 'addMapvLayer', 'removeMapvLayer']
286
+ methodEx = methodEx.concat(methodBusEx);
287
+ for (let index = 0; index < methodEx.length; index++) {
288
+ var funcName = methodEx[index];
289
+ that[funcName] = function(method){
290
+ return function (){
291
+ return that.callMap(method,arguments);
292
+ }
293
+ }(funcName);
294
+ }
295
+
296
+ that.init();
297
+ }
298
+
299
+ export default EGovaMobileMap;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "egovamap",
3
- "version": "0.16.8",
3
+ "version": "0.17.1",
4
4
  "description": "eUrbanGIS SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {