Skip to content

Commit 85f790a

Browse files
committed
leaflet theme默认叠加4326坐标要素。增加alwaysMapCRS参数,设置该参数为true可叠加地图坐标参数
1 parent 4272c81 commit 85f790a

11 files changed

Lines changed: 39 additions & 26 deletions

dist/iclient9-leaflet.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/iclient9-leaflet.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26150,7 +26150,7 @@ var GeoFeatureThemeLayer = exports.GeoFeatureThemeLayer = _ThemeLayer.ThemeLayer
2615026150
if (hoverone && hoverone.refDataID) {
2615126151
hoverFid = hoverone.refDataID;
2615226152
}
26153-
if (bounds && bounds instanceof _leaflet2["default"].LatLngBounds) {
26153+
if (this.options.alwaysMapCRS && bounds && bounds instanceof _leaflet2["default"].LatLngBounds) {
2615426154
var crs = this._map.options.crs;
2615526155
bounds = _leaflet2["default"].bounds(crs.project(bounds.getSouthWest()), crs.project(bounds.getNorthEast()));
2615626156
}
@@ -28677,7 +28677,7 @@ var GraphThemeLayer = exports.GraphThemeLayer = _ThemeLayer.ThemeLayer.extend({
2867728677
//清除当前所有可视元素
2867828678
me.renderer.clearAll();
2867928679
var features = me.features;
28680-
if (bounds && bounds instanceof _leaflet2["default"].LatLngBounds) {
28680+
if (this.options.alwaysMapCRS && bounds && bounds instanceof _leaflet2["default"].LatLngBounds) {
2868128681
var crs = this._map.options.crs;
2868228682
bounds = _leaflet2["default"].bounds(crs.project(bounds.getSouthWest()), crs.project(bounds.getNorthEast()));
2868328683
}
@@ -28987,7 +28987,9 @@ var GraphThemeLayer = exports.GraphThemeLayer = _ThemeLayer.ThemeLayer.extend({
2898728987
// 压盖判断所需 chartsBounds 集合
2898828988
var mapBounds = me._map.getBounds();
2898928989
var crs = this._map.options.crs;
28990-
mapBounds = _leaflet2["default"].bounds(crs.project(mapBounds.getSouthWest()), crs.project(mapBounds.getNorthEast()));
28990+
if (this.options.alwaysMapCRS) {
28991+
mapBounds = _leaflet2["default"].bounds(crs.project(mapBounds.getSouthWest()), crs.project(mapBounds.getNorthEast()));
28992+
}
2899128993
mapBounds = _CommontypesConversion.CommontypesConversion.toSuperMapBounds(mapBounds);
2899228994
var charts = me.charts;
2899328995
var chartsBounds = [];
@@ -29329,9 +29331,9 @@ var LabelThemeLayer = exports.LabelThemeLayer = _GeoFeatureThemeLayer.GeoFeature
2932929331
}
2933029332

2933129333
//屏蔽有偏移性质的style属性,偏移量在算bounds时已经加入计算
29332-
var leftBottom = map.options.crs.project(geoBs[3]);
29333-
var rightTop = map.options.crs.project(geoBs[1]);
29334-
var bounds = new _iclientCommon.Bounds(leftBottom.x, leftBottom.y, rightTop.x, [rightTop.y]);
29334+
var leftBottom = geoBs[3];
29335+
var rightTop = geoBs[1];
29336+
var bounds = new _iclientCommon.Bounds(leftBottom.lng, leftBottom.lat, rightTop.lng, rightTop.lat);
2933529337
var center = bounds.getCenterLonLat();
2933629338
var label = new _iclientCommon.GeoText(center.lon, center.lat, fi.attributes[this.themeField]);
2933729339
label.calculateBounds();
@@ -29488,7 +29490,7 @@ var LabelThemeLayer = exports.LabelThemeLayer = _GeoFeatureThemeLayer.GeoFeature
2948829490

2948929491
//将标签的地理位置转为像素位置
2949029492
var locationTmp = geoText.getCentroid();
29491-
var locTmp = this._map.latLngToContainerPoint(this._map.options.crs.unproject(_leaflet2["default"].point(locationTmp.x, locationTmp.y)));
29493+
var locTmp = this._map.latLngToContainerPoint(!this.options.alwaysMapCRS ? _leaflet2["default"].latLng(locationTmp.y, locationTmp.x) : this._map.options.crs.unproject(_leaflet2["default"].point(locationTmp.x, locationTmp.y)));
2949229494
var loc = _leaflet2["default"].point(locTmp.x, locTmp.y);
2949329495

2949429496
//偏移处理
@@ -55470,6 +55472,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
5547055472
var ThemeLayer = exports.ThemeLayer = _leaflet2["default"].Layer.extend({
5547155473

5547255474
options: {
55475+
//要素坐标是否和地图坐标系一致,默认为false,要素默认是经纬度坐标。
55476+
alwaysMapCRS: false,
5547355477
name: null,
5547455478
opacity: 1,
5547555479
// {Array} 专题要素事件临时存储,临时保存图层未添加到 map 前用户添加的事件监听,待图层添加到 map 后把这些事件监听添加到图层上,清空此图层。
@@ -55846,14 +55850,15 @@ var ThemeLayer = exports.ThemeLayer = _leaflet2["default"].Layer.extend({
5584655850
var coor = coordinate;
5584755851
if (_leaflet2["default"].Util.isArray(coordinate)) {
5584855852
coor = _leaflet2["default"].point(coordinate[0], coordinate[1]);
55849-
} else if (!(coordinate instanceof _leaflet2["default"].Point)) {
55853+
}
55854+
if (!(coordinate instanceof _leaflet2["default"].Point)) {
5585055855
if (coordinate instanceof _iclientCommon.GeometryPoint || coordinate instanceof _iclientCommon.GeoText) {
5585155856
coor = _leaflet2["default"].point(coordinate.x, coordinate.y);
5585255857
} else {
5585355858
coor = _leaflet2["default"].point(coordinate.lon, coordinate.lat);
5585455859
}
5585555860
}
55856-
var point = this._map.latLngToContainerPoint(this._map.options.crs.unproject(coor));
55861+
var point = this._map.latLngToContainerPoint(!this.options.alwaysMapCRS ? _leaflet2["default"].latLng(coor.y, coor.x) : this._map.options.crs.unproject(coor));
5585755862
return [point.x, point.y];
5585855863
},
5585955864

@@ -94335,7 +94340,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
9433594340
/* 500 */
9433694341
/***/ (function(module, exports) {
9433794342

94338-
module.exports = {"_from":"proj4@2.3.15","_id":"proj4@2.3.15","_inBundle":false,"_integrity":"sha1-WtBui8owvg/6OJpJ5FZfUfBtCJ4=","_location":"/proj4","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"proj4@2.3.15","name":"proj4","escapedName":"proj4","rawSpec":"2.3.15","saveSpec":null,"fetchSpec":"2.3.15"},"_requiredBy":["/"],"_resolved":"https://registry.npmjs.org/proj4/-/proj4-2.3.15.tgz","_shasum":"5ad06e8bca30be0ffa389a49e4565f51f06d089e","_spec":"proj4@2.3.15","_where":"F:\\dev\\iClient","author":"","bugs":{"url":"https://github.com/proj4js/proj4js/issues"},"bundleDependencies":false,"contributors":[{"name":"Mike Adair","email":"madair@dmsolutions.ca"},{"name":"Richard Greenwood","email":"rich@greenwoodmap.com"},{"name":"Calvin Metcalf","email":"calvin.metcalf@gmail.com"},{"name":"Richard Marsden","url":"http://www.winwaed.com"},{"name":"T. Mittan"},{"name":"D. Steinwand"},{"name":"S. Nelson"}],"dependencies":{"mgrs":"~0.0.2"},"deprecated":false,"description":"Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.","devDependencies":{"browserify":"~12.0.1","chai":"~1.8.1","curl":"git://github.com/cujojs/curl.git","grunt":"~0.4.2","grunt-browserify":"~4.0.1","grunt-cli":"~0.1.13","grunt-contrib-connect":"~0.6.0","grunt-contrib-jshint":"~0.8.0","grunt-contrib-uglify":"~0.11.1","grunt-mocha-phantomjs":"~0.4.0","istanbul":"~0.2.4","mocha":"~1.17.1","tin":"~0.4.0"},"directories":{"test":"test","doc":"docs"},"homepage":"https://github.com/proj4js/proj4js#readme","jam":{"main":"dist/proj4.js","include":["dist/proj4.js","README.md","AUTHORS","LICENSE.md"]},"license":"MIT","main":"lib/index.js","name":"proj4","repository":{"type":"git","url":"git://github.com/proj4js/proj4js.git"},"scripts":{"test":"./node_modules/istanbul/lib/cli.js test ./node_modules/mocha/bin/_mocha test/test.js"},"version":"2.3.15"}
94343+
module.exports = {"_args":[["proj4@2.3.15","E:\\git\\iClient9"]],"_from":"proj4@2.3.15","_id":"proj4@2.3.15","_inBundle":false,"_integrity":"sha1-WtBui8owvg/6OJpJ5FZfUfBtCJ4=","_location":"/proj4","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"proj4@2.3.15","name":"proj4","escapedName":"proj4","rawSpec":"2.3.15","saveSpec":null,"fetchSpec":"2.3.15"},"_requiredBy":["/"],"_resolved":"http://registry.npm.taobao.org/proj4/download/proj4-2.3.15.tgz","_spec":"2.3.15","_where":"E:\\git\\iClient9","author":"","bugs":{"url":"https://github.com/proj4js/proj4js/issues"},"contributors":[{"name":"Mike Adair","email":"madair@dmsolutions.ca"},{"name":"Richard Greenwood","email":"rich@greenwoodmap.com"},{"name":"Calvin Metcalf","email":"calvin.metcalf@gmail.com"},{"name":"Richard Marsden","url":"http://www.winwaed.com"},{"name":"T. Mittan"},{"name":"D. Steinwand"},{"name":"S. Nelson"}],"dependencies":{"mgrs":"~0.0.2"},"description":"Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.","devDependencies":{"browserify":"~12.0.1","chai":"~1.8.1","curl":"git://github.com/cujojs/curl.git","grunt":"~0.4.2","grunt-browserify":"~4.0.1","grunt-cli":"~0.1.13","grunt-contrib-connect":"~0.6.0","grunt-contrib-jshint":"~0.8.0","grunt-contrib-uglify":"~0.11.1","grunt-mocha-phantomjs":"~0.4.0","istanbul":"~0.2.4","mocha":"~1.17.1","tin":"~0.4.0"},"directories":{"test":"test","doc":"docs"},"homepage":"https://github.com/proj4js/proj4js#readme","jam":{"main":"dist/proj4.js","include":["dist/proj4.js","README.md","AUTHORS","LICENSE.md"]},"license":"MIT","main":"lib/index.js","name":"proj4","repository":{"type":"git","url":"git://github.com/proj4js/proj4js.git"},"scripts":{"test":"./node_modules/istanbul/lib/cli.js test ./node_modules/mocha/bin/_mocha test/test.js"},"version":"2.3.15"}
9433994344

9434094345
/***/ }),
9434194346
/* 501 */

dist/iclient9-leaflet.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/iclient9-leaflet.min.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/leaflet/labelThemeLayer.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
var host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090";
2727
var map, themeLayer, infoView,
28-
baseUrl = host + "/iserver/services/map-china400/rest/maps/China_4326";
28+
baseUrl = host + "/iserver/services/map-china400/rest/maps/China";
2929

3030
init();
3131

@@ -37,7 +37,7 @@
3737
}
3838

3939
map = L.map("map", {
40-
crs: L.CRS.EPSG4326,
40+
crs: L.CRS.EPSG3857,
4141
center: [35, 106],
4242
maxZoom: 18,
4343
zoom: 3

examples/leaflet/rangeThemeLayer.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
themeLayer = L.supermap.rangeThemeLayer("ThemeLayer", {
4646
// 开启 hover 高亮效果
4747
isHoverAble: true,
48-
opacity: 0.8
48+
opacity: 0.8,
49+
alwaysMapCRS:true
4950
}).addTo(map);
5051

5152
themeLayer.style = new SuperMap.ThemeStyle({

examples/leaflet/uniqueThemeLayer.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
themeLayer = L.supermap.uniqueThemeLayer("ThemeLayer", {
4747
// 开启 hover 高亮效果
4848
isHoverAble: true,
49-
opacity: 0.8
49+
opacity: 0.8,
50+
alwaysMapCRS:true
5051
}).addTo(map);
5152

5253
// 图层基础样式

src/leaflet/overlay/GraphThemeLayer.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export var GraphThemeLayer = ThemeLayer.extend({
100100
//清除当前所有可视元素
101101
me.renderer.clearAll();
102102
var features = me.features;
103-
if (bounds && bounds instanceof L.LatLngBounds) {
103+
if (this.options.alwaysMapCRS && bounds && bounds instanceof L.LatLngBounds) {
104104
var crs = this._map.options.crs;
105105
bounds = L.bounds(crs.project(bounds.getSouthWest()), crs.project(bounds.getNorthEast()));
106106
}
@@ -412,7 +412,9 @@ export var GraphThemeLayer = ThemeLayer.extend({
412412
// 压盖判断所需 chartsBounds 集合
413413
var mapBounds = me._map.getBounds();
414414
var crs = this._map.options.crs;
415-
mapBounds = L.bounds(crs.project(mapBounds.getSouthWest()), crs.project(mapBounds.getNorthEast()));
415+
if(this.options.alwaysMapCRS ){
416+
mapBounds = L.bounds(crs.project(mapBounds.getSouthWest()), crs.project(mapBounds.getNorthEast()));
417+
}
416418
mapBounds = CommontypesConversion.toSuperMapBounds(mapBounds);
417419
var charts = me.charts;
418420
var chartsBounds = [];

src/leaflet/overlay/LabelThemeLayer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ export var LabelThemeLayer = GeoFeatureThemeLayer.extend({
245245
}
246246

247247
//屏蔽有偏移性质的style属性,偏移量在算bounds时已经加入计算
248-
var leftBottom = map.options.crs.project(geoBs[3]);
249-
var rightTop = map.options.crs.project(geoBs[1]);
250-
var bounds = new Bounds(leftBottom.x, leftBottom.y, rightTop.x, [rightTop.y]);
248+
var leftBottom = geoBs[3];
249+
var rightTop = geoBs[1];
250+
var bounds = new Bounds(leftBottom.lng, leftBottom.lat, rightTop.lng, rightTop.lat);
251251
var center = bounds.getCenterLonLat();
252252
var label = new GeoText(center.lon, center.lat, fi.attributes[this.themeField]);
253253
label.calculateBounds();
@@ -404,7 +404,7 @@ export var LabelThemeLayer = GeoFeatureThemeLayer.extend({
404404

405405
//将标签的地理位置转为像素位置
406406
var locationTmp = geoText.getCentroid();
407-
var locTmp = this._map.latLngToContainerPoint(this._map.options.crs.unproject(L.point(locationTmp.x, locationTmp.y)));
407+
var locTmp = this._map.latLngToContainerPoint(!this.options.alwaysMapCRS?L.latLng(locationTmp.y,locationTmp.x):this._map.options.crs.unproject(L.point(locationTmp.x, locationTmp.y)));
408408
var loc = L.point(locTmp.x, locTmp.y);
409409

410410
//偏移处理

src/leaflet/overlay/theme/GeoFeatureThemeLayer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export var GeoFeatureThemeLayer = ThemeLayer.extend({
126126
if (hoverone && hoverone.refDataID) {
127127
hoverFid = hoverone.refDataID;
128128
}
129-
if (bounds && bounds instanceof L.LatLngBounds) {
129+
if (this.options.alwaysMapCRS && bounds && bounds instanceof L.LatLngBounds) {
130130
var crs = this._map.options.crs;
131131
bounds = L.bounds(crs.project(bounds.getSouthWest()), crs.project(bounds.getNorthEast()));
132132
}

0 commit comments

Comments
 (0)