开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 50

wolfbruce/MapGIS-WebClient-JavaScript

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (40)
标签 (9)
master
10.6.0.10
dev
10.6.0
yangkun
webclient_plot
10.5.6
yangkun_tiedi
yangkun_plot
10.5.5
master_fixbug
lzt_dev
dependabot/npm_and_yarn/website/follow-redirects-1.14.8
dependabot/npm_and_yarn/website/node-sass-7.0.0
dependabot/npm_and_yarn/website/postcss-7.0.39
cesium_1_84
ljy
yangkun_12_9
yangkun_12_3
mapvToMaster
10.6.0.10
10.5.6.10
10.5.5.14
10.5.5.13
onemap_10.5.4.10
v10.5.5.10
ceping
v10.5.4.10
10.5.3.10
master
分支 (40)
标签 (9)
master
10.6.0.10
dev
10.6.0
yangkun
webclient_plot
10.5.6
yangkun_tiedi
yangkun_plot
10.5.5
master_fixbug
lzt_dev
dependabot/npm_and_yarn/website/follow-redirects-1.14.8
dependabot/npm_and_yarn/website/node-sass-7.0.0
dependabot/npm_and_yarn/website/postcss-7.0.39
cesium_1_84
ljy
yangkun_12_9
yangkun_12_3
mapvToMaster
10.6.0.10
10.5.6.10
10.5.5.14
10.5.5.13
onemap_10.5.4.10
v10.5.5.10
ceping
v10.5.4.10
10.5.3.10
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (40)
标签 (9)
master
10.6.0.10
dev
10.6.0
yangkun
webclient_plot
10.5.6
yangkun_tiedi
yangkun_plot
10.5.5
master_fixbug
lzt_dev
dependabot/npm_and_yarn/website/follow-redirects-1.14.8
dependabot/npm_and_yarn/website/node-sass-7.0.0
dependabot/npm_and_yarn/website/postcss-7.0.39
cesium_1_84
ljy
yangkun_12_9
yangkun_12_3
mapvToMaster
10.6.0.10
10.5.6.10
10.5.5.14
10.5.5.13
onemap_10.5.4.10
v10.5.5.10
ceping
v10.5.4.10
10.5.3.10
ThemeLayer.js 16.73 KB
一键复制 编辑 原始数据 按行查看 历史
zhangchunzhou 提交于 2021年04月14日 16:21 +08:00 . Add sources file of client-side spatial Analysis.
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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501
import {Zondy} from '../../service/common/Base';
import {L} from 'leaflet';
import {modifyDOMElement} from "../../service/common/Util";
import {LevelRenderer} from '../../common/overlay/levelRender/LevelRenderer';
/**
* @class Zondy.Map.ThemeLayer
* @classdesc 专题图层基类,调用建议使用其子类实现类。
* @extends {L.Layer}
* @param {string} name - 专题图图层名称。
* @param {Object} options - 可选参数。
* @param {string} [options.id] - 专题图层 ID。默认使用 CommonUtil.createUniqueID("themeLayer_") 创建专题图层 ID。
* @param {number} [options.opacity=1] - 图层透明度。
* @fires Zondy.Map.ThemeLayer#featuresremoved
*/
var ThemeLayer = window.L.Layer.extend({
options: {
name: null,
opacity: 1,
// {Array} 专题要素事件临时存储,临时保存图层未添加到 map 前用户添加的事件监听,待图层添加到 map 后把这些事件监听添加到图层上,清空此图层。
//这是一个二维数组,组成二维数组的每个一维数组长度为 2,分别是 event, callback。
TFEvents: null
},
initialize: function (name, options) {
window.L.Util.setOptions(this, options);
this.options.name = name;
this.features = [];
this.TFEvents = options && options.TFEvents ? options.TFEvents : [];
this.levelRenderer = new LevelRenderer();
this.movingOffset = [0, 0];
},
/**
* @function Zondy.Map.ThemeLayer.prototype.getEvents
* @description 获取图层事件。
* @returns {Object} 返回图层支持的事件。
*/
getEvents: function () {
var me = this;
var events = {
zoomend: me._reset,
moveend: me._reset,
resize: me._resize
};
if (this._map._zoomAnimated) {
events.zoomanim = me._zoomAnim;
}
return events;
},
/**
* @function Zondy.Map.ThemeLayer.prototype.onRemove
* @description 删除某个地图。
* @param {L.Map} map - 要删除的地图。
*/
onRemove: function (map) {
var me = this;
window.L.DomUtil.remove(me.container);
map.off("mousemove", me.mouseMoveHandler);
},
/**
* @function Zondy.Map.ThemeLayer.prototype.onAdd
* @description 添加专题图。
* @param {L.Map} map - 要添加的地图。
* @private
*/
onAdd: function (map) {
var me = this;
me.map = me._map = map;
me._initContainer();
if (!me.levelRenderer) {
map.removeLayer(me);
return;
}
//初始化渲染器
var size = map.getSize();
me.container.style.width = size.x + "px";
me.container.style.height = size.y + "px";
me._updateOpacity();
me.renderer = me.levelRenderer.init(me.container);
me.renderer.clear();
if (me.features && me.features.length > 0) {
me._reset();
}
//处理用户预先(在图层添加到 map 前)监听的事件
me.addTFEvents();
me.mouseMoveHandler = function (e) {
var xy = e.layerPoint;
me.currentMousePosition = window.L.point(xy.x + me.movingOffset[0], xy.y + me.movingOffset[1]);
};
map.on("mousemove", me.mouseMoveHandler);
me.update();
},
/**
* @function Zondy.Map.ThemeLayer.prototype.addFeatures
* @description 向专题图图层中添加数据。
* @param {Object} features - 待转要素。
*/
addFeatures: function (features) { // eslint-disable-line no-unused-vars
//子类实现此方法
},
/**
* @function Zondy.Map.ThemeLayer.prototype.redrawThematicFeatures
* @description 抽象方法,可实例化子类必须实现此方法。
* @param {L.bounds} bounds - 重绘专题要素范围。
*/
redrawThematicFeatures: function (bounds) { // eslint-disable-line no-unused-vars
//子类必须实现此方法
},
/**
* @function Zondy.Map.ThemeLayer.prototype.destroyFeatures
* @description 销毁要素。
* @param {Array.<Zondy.Feature.Vector>} features - 将被销毁的要素。
*/
destroyFeatures: function (features) {
if (features === undefined) {
features = this.features;
}
if (!features) {
return;
}
this.removeFeatures(features);
for (var i = features.length - 1; i >= 0; i--) {
features[i].destroy();
}
},
/**
* @function Zondy.Map.ThemeLayer.prototype.removeFeatures
* @description 从专题图中删除 feature。这个函数删除所有传递进来的矢量要素。
* @param {Array.<Zondy.Feature.Vector>} features - 将被删除的要素。
*/
removeFeatures: function (features) {
var me = this;
if (!features || features.length === 0) {
return;
}
if (features === me.features) {
return me.removeAllFeatures();
}
if (!(window.L.Util.isArray(features))) {
features = [features];
}
var featuresFailRemoved = [];
for (var i = features.length - 1; i >= 0; i--) {
var feature = features[i];
//如果我们传入的feature在features数组中没有的话,则不进行删除,
//并将其放入未删除的数组中。
var findex = window.L.Util.indexOf(me.features, feature);
if (findex === -1) {
featuresFailRemoved.push(feature);
continue;
}
me.features.splice(findex, 1);
}
var drawFeatures = [];
for (var hex = 0, len = me.features.length; hex < len; hex++) {
feature = me.features[hex];
drawFeatures.push(feature);
}
me.features = [];
me.addFeatures(drawFeatures);
//绘制专题要素
if (me.renderer) {
if (me._map) {
me.redrawThematicFeatures(me._map.getBounds());
} else {
me.redrawThematicFeatures();
}
}
var succeed = featuresFailRemoved.length === 0;
/**
* @event Zondy.Map.ThemeLayer#featuresremoved
* @description 删除的要素成功之后触发。
* @property {Array.<Zondy.Feature.Vector>} features - 事件对象。
* @property {boolean} succeed - 要输是否删除成功,true 为删除成功,false 为删除失败。
*/
me.fire("featuresremoved", {
features: featuresFailRemoved,
succeed: succeed
});
},
/**
* @function Zondy.Map.ThemeLayer.prototype.removeAllFeatures
* @description 清除当前图层所有的矢量要素。
*/
removeAllFeatures: function () {
var me = this;
if (me.renderer) {
me.renderer.clear();
}
me.features = [];
me.fire("featuresremoved", {
features: [],
succeed: true
});
},
/**
* @function Zondy.Map.ThemeLayer.prototype.getFeatures
* @description 查看当前图层中的有效数据。
* @returns {Array} 返回图层中的有效数据。
*/
getFeatures: function () {
var me = this;
var len = me.features.length;
var clonedFeatures = new Array(len);
for (var i = 0; i < len; ++i) {
clonedFeatures[i] = me.features[i];
}
return clonedFeatures;
},
/**
* @function Zondy.Map.ThemeLayer.prototype.getFeatureBy
* @description 在专题图的要素数组 features 里面遍历每一个 feature,当 feature[property] === value 时,返回此 feature(并且只返回第一个)。
* @param {string} property - 要的某个属性名。
* @param {string} value - 对应属性名得值。
*/
getFeatureBy: function (property, value) {
var me = this;
var feature = null;
for (var id in me.features) {
if (me.features[id][property] !== value) {
continue;
}
feature = me.features[id];
break;
}
return feature;
},
/**
* @function Zondy.Map.ThemeLayer.prototype.getFeatureById
* @description 通过给定一个 ID,返回对应的矢量要素,如果不存在则返回 null。
* @param {number} featureId - 要素 ID。
*/
getFeatureById: function (featureId) {
return this.getFeatureBy('FID', featureId);
},
/**
* @function Zondy.Map.ThemeLayer.prototype.getFeaturesByAttribute
* @description 通过给定一个属性的 key 值和 value 值,返回所有匹配的要素数组。
* @param {string} attrName - key 值。
* @param {string} attrValue - value 值。
* @returns {Array} 返回所有匹配的要素数组。
*/
getFeaturesByAttribute: function (attrName, attrValue) {
var me = this,
feature,
foundFeatures = [];
for (var id in me.features) {
feature = me.features[id];
if (feature && feature.attributes && (feature.attributes[attrName] === attrValue)) {
foundFeatures.push(feature);
}
}
return foundFeatures;
},
/**
* @function Zondy.Map.ThemeLayer.prototype.update
* @description 更新图层。
* @param {L.bounds} bounds - 图层范围。
*/
update: function (bounds) {
var mapOffset = this._map.containerPointToLayerPoint([0, 0]);
window.L.DomUtil.setPosition(this.container, mapOffset);
var me = this;
// var bounds = me._map.getBounds();
// var topLeft = me._map.latLngToLayerPoint(bounds.getNorthWest());
// var mapOffset = [parseInt(topLeft.x, 10) || 0, parseInt(topLeft.y, 10) || 0]
// // var offsetLeft = parseInt(me._map.getContainer().style.left, 10);
// // offsetLeft = -Math.round(offsetLeft);
// //var offsetTop = parseInt(me._map.getContainer().style.top, 10);
// //offsetTop = -Math.round(offsetTop);
// me.container.style.left = mapOffset[0] + 'px';
// me.container.style.top = mapOffset[1] + 'px';
//绘制专题要素
if (me.renderer) {
me.redrawThematicFeatures(bounds);
}
if (me.currentMousePosition) {
me.currentMousePosition = window.L.point(
me.currentMousePosition.x - me.movingOffset[0],
me.currentMousePosition.y - me.movingOffset[1]);
}
me.movingOffset = [0, 0];
me._zoom = me._map.getZoom();
me._center = me._map.getCenter();
},
/**
* @function Zondy.Map.ThemeLayer.prototype.setOpacity
* @description 设置图层的不透明度,取值 [0-1] 之间。
* @param {number} opacity - 不透明度。
*/
setOpacity: function (opacity) {
var me = this;
if (opacity === me.options.opacity) {
return;
}
if (!isNaN(opacity)) {
me.options.opacity = opacity;
me._updateOpacity();
}
},
/**
* @function Zondy.Map.ThemeLayer.prototype.redraw
* @description 重绘该图层。
* @returns {boolean} 返回是否重绘成功。
*/
redraw: function () {
var me = this;
if (!me.renderer) {
return false;
}
if (me._map) {
me.redrawThematicFeatures(me._map.getBounds());
} else {
me.redrawThematicFeatures();
}
return true;
},
/**
* @function Zondy.Map.ThemeLayer.prototype.on
* @description 添加专题要素事件监听。添加专题要素事件监听。
* @param {Event} event - 监听事件。
* @param {Function} callback - 回调函数。
* @param {string} context - 信息。
*/
on: function (event, callback, context) { // eslint-disable-line no-unused-vars
if (this.renderer) {
this.renderer.on(event, callback);
} else {
window.L.Layer.prototype.on.call(this, event, callback);
}
return this;
},
/**
* @function Zondy.Map.ThemeLayer.prototype.off
* @description 移除专题要素事件监听。
* @param {Event} event - 监听事件。
* @param {Function} callback - 回调函数。
* @param {string} context - 信息。
*/
off: function (event, callback, context) { // eslint-disable-line no-unused-vars
var me = this;
if (me.renderer) {
me.renderer.un(event, callback);
} else {
window.L.Layer.prototype.off.call(this, event, callback);
}
return this;
},
fire: function (type, data, propagate) { // eslint-disable-line no-unused-vars
if (this.renderer) {
this.renderer.trigger(type, data);
}
window.L.Layer.prototype.fire.call(this, type, data, propagate);
return this;
},
/**
* @function Zondy.Map.ThemeLayer.prototype.addTFEvents
* @description 将图层添加到地图上之前用户要求添加的事件监听添加到图层。
* @private
*/
addTFEvents: function () {
var me = this;
var tfEs = me.TFEvents;
var len = tfEs.length;
for (var i = 0; i < len; i++) {
me.renderer.on(tfEs[i][0], tfEs[i][1]);
}
},
/**
* @function Zondy.Map.ThemeLayer.prototype.getLocalXY
* @description 地理坐标转为像素坐标。
* @param {Array} coordinate
*/
getLocalXY: function (coordinate) {
if (!this._map) {
return coordinate;
}
var coor = coordinate;
if (window.L.Util.isArray(coordinate)) {
coor = window.L.point(coordinate[0], coordinate[1]);
} else if (!(coordinate instanceof window.L.Point)) {
if (coordinate instanceof Zondy.LonLat) {
coor = window.L.point(coordinate.lon, coordinate.lat);
} else {
coor = window.L.point(coordinate.x, coordinate.y);
}
}
var point = this._map.latLngToContainerPoint(this._map.options.crs.unproject(coor));
return [point.x, point.y];
},
_initContainer: function () {
var parentContainer = this.getPane();
var animated = this._map.options.zoomAnimation && window.L.Browser.any3d;
var className = this.options.name || "themeLayer";
className += ' leaflet-layer leaflet-zoom-' + (animated ? 'animated' : 'hide');
this.container = window.L.DomUtil.create("div", className, parentContainer);
var originProp = window.L.DomUtil.testProp(['transformOrigin', 'WebkitTransformOrigin', 'msTransformOrigin']);
this.container.style[originProp] = '50% 50%';
this.container.style.position = "absolute";
this.container.style.zIndex = 200;
},
_zoomAnim: function (e) {
var scale = this._map.getZoomScale(e.zoom),
offset = this._map._getCenterOffset(e.center)._multiplyBy(-scale).subtract(this._map._getMapPanePos());
if (window.L.DomUtil.setTransform) {
window.L.DomUtil.setTransform(this.container, offset, scale);
} else {
this.container.style[window.L.DomUtil.TRANSFORM] = window.L.DomUtil.getTranslateString(offset) + ' scale(' + scale + ')';
}
},
_updateOpacity: function () {
var me = this;
modifyDOMElement(me.container, null, null, null, null, null, null, me.options.opacity);
if (me._map !== null) {
/**
* @event Zondy.Map.ThemeLayer#changelayer
* @description 图层属性改变之后触发。
* @property {Object} layer - 图层。
* @property {string} property - 图层属性。
*/
me._map.fire("changelayer", {
layer: me,
property: "opacity"
});
}
},
//缩放移动重绘
_reset: function () {
var me = this;
var latLngBounds = me._map.getBounds();
me.update(latLngBounds);
var size = me._map.getSize();
var mapOffset = this._map.containerPointToLayerPoint([0, 0]);
window.L.DomUtil.setPosition(this.container, mapOffset);
if (parseFloat(me.container.width) !== parseFloat(size.x)) {
me.container.width = size.x + 'px';
}
if (parseFloat(me.container.height) !== parseFloat(size.y)) {
me.container.height = size.y + 'px';
}
me.redraw();
},
//通知渲染器的尺寸变化
_resize: function () {
var me = this;
var newSize = me._map.getSize();
me.container.style.width = newSize.x + "px";
me.container.style.height = newSize.y + "px";
me.renderer.resize();
}
});
export {ThemeLayer};
Zondy.Map.ThemeLayer = ThemeLayer;
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

MapGIS Client for JavaScript:为云GIS网络客户端开发平台,将传统WebGIS与云GIS完美融合, 集成Cesium、MapboXGL,、Leaflet、OpenLayers四大主流地图开源框架和Echarts、MapV、D3等可视化库,进一步增强了大数据、实时流数据的高效可视化表达和分析功能。
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/wolfbruce/WebClient-JavaScript.git
git@gitee.com:wolfbruce/WebClient-JavaScript.git
wolfbruce
WebClient-JavaScript
MapGIS-WebClient-JavaScript
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /