@vtx/map 1.0.8 → 1.1.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.
@@ -14,6 +14,9 @@
14
14
  position: relative;
15
15
  white-space: inherit !important;
16
16
  }
17
+ .amap-info-content {
18
+ padding: 0 !important;
19
+ }
17
20
  .vtx_gmap_html_pointCollection_a {
18
21
  position: absolute;
19
22
  top: 0px;
@@ -12,6 +12,8 @@ var _react = require('react');
12
12
 
13
13
  var _react2 = _interopRequireDefault(_react);
14
14
 
15
+ var _reactDom = require('react-dom');
16
+
15
17
  require('./AMap.css');
16
18
 
17
19
  var _MapToolFunction = require('../MapToolFunction');
@@ -168,7 +170,8 @@ var VortexAMap = function (_React$Component) {
168
170
  boundaryName = _t$props.boundaryName,
169
171
  heatMapData = _t$props.heatMapData,
170
172
  areaRestriction = _t$props.areaRestriction,
171
- coverageType = _t$props.coverageType;
173
+ coverageType = _t$props.coverageType,
174
+ infoWindowData = _t$props.infoWindowData;
172
175
  // 切换地图矢量图和卫星图背景
173
176
 
174
177
  if (coverageType) {
@@ -239,6 +242,10 @@ var VortexAMap = function (_React$Component) {
239
242
  if (heatMapData) {
240
243
  t.heatMapOverlay(heatMapData);
241
244
  }
245
+ // 打开信息窗体
246
+ if (infoWindowData) {
247
+ t.infoWindow(infoWindowData);
248
+ }
242
249
  //添加海量点
243
250
  if (mapPointCollection instanceof Array) {
244
251
  t.addPointCollection(mapPointCollection);
@@ -651,10 +658,16 @@ var VortexAMap = function (_React$Component) {
651
658
  ids = obj.fitView.split(',');
652
659
  }
653
660
  if (ids[0] instanceof Array) {
654
- var l = new AMap.LngLat(ids[0][0], ids[0][1]),
655
- r = new AMap.LngLat(ids[1][0], ids[1][1]);
656
- var b = new AMap.Bounds(l, r);
657
- t.state.gis.setBounds(b);
661
+ // let l = new AMap.LngLat(ids[0][0],ids[0][1]),
662
+ // r = new AMap.LngLat(ids[1][0],ids[1][1]);
663
+ // let b = new AMap.Bounds(l,r);
664
+ // t.state.gis.setBounds(b);
665
+ // fix: 高德地图在[[lng,lat],[lng,lat]]方式下的最佳视野
666
+ t.state.gis.setFitView(ids.map(function (item) {
667
+ return new AMap.Marker({
668
+ position: new AMap.LngLat(item[0], item[1])
669
+ });
670
+ }));
658
671
  } else {
659
672
  t.state.gis.setFitView(this.GM.getMoreGraphic(ids));
660
673
  }
@@ -1020,6 +1033,45 @@ var VortexAMap = function (_React$Component) {
1020
1033
  t.heatmap.hide();
1021
1034
  }
1022
1035
  }
1036
+ // 信息窗体
1037
+
1038
+ }, {
1039
+ key: 'infoWindow',
1040
+ value: function (_infoWindow) {
1041
+ function infoWindow() {
1042
+ return _infoWindow.apply(this, arguments);
1043
+ }
1044
+
1045
+ infoWindow.toString = function () {
1046
+ return _infoWindow.toString();
1047
+ };
1048
+
1049
+ return infoWindow;
1050
+ }(function () {
1051
+ var d = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1052
+
1053
+ var t = this;
1054
+ var cg = {
1055
+ width: 300,
1056
+ height: 172
1057
+ };
1058
+ if (d.config) {
1059
+ cg = _extends({}, cg, d.config);
1060
+ }
1061
+ var sContent = document.createElement('div');
1062
+ var infowindow = new AMap.InfoWindow({
1063
+ // isCustom: true,
1064
+ content: sContent
1065
+ });
1066
+ infowindow.setSize(new AMap.Size(cg.width, cg.height + 20));
1067
+
1068
+ if (d.lat && d.lng && d.content) {
1069
+ (0, _reactDom.render)(d.content, sContent);
1070
+ infowindow.open(t.state.gis, [d.lng, d.lat]);
1071
+ } else {
1072
+ infoWindow.close();
1073
+ }
1074
+ })
1023
1075
  //添加海量点
1024
1076
 
1025
1077
  }, {
@@ -2612,7 +2664,8 @@ var VortexAMap = function (_React$Component) {
2612
2664
  areaRestriction = nextProps.areaRestriction,
2613
2665
  isClearAreaRestriction = nextProps.isClearAreaRestriction,
2614
2666
  mapStyle = nextProps.mapStyle,
2615
- coverageType = nextProps.coverageType;
2667
+ coverageType = nextProps.coverageType,
2668
+ infoWindowData = nextProps.infoWindowData;
2616
2669
 
2617
2670
  var props = t.props;
2618
2671
  // 设置地图样式
@@ -2934,6 +2987,10 @@ var VortexAMap = function (_React$Component) {
2934
2987
  if (heatMapData && !t.deepEqual(heatMapData, props.heatMapData)) {
2935
2988
  t.heatMapOverlay(heatMapData);
2936
2989
  }
2990
+ // 打开信息窗体
2991
+ if (infoWindowData && !t.deepEqual(infoWindowData, t.props.infoWindowData)) {
2992
+ t.infoWindow(infoWindowData);
2993
+ }
2937
2994
  //添加图片图层
2938
2995
  if (imageOverlays instanceof Array && props.imageOverlays instanceof Array && !t.deepEqual(imageOverlays, props.imageOverlays)) {
2939
2996
  t.imageUrlOverlay(imageOverlays);
@@ -14,6 +14,9 @@
14
14
  position: relative;
15
15
  white-space: inherit !important;
16
16
  }
17
+ .amap-info-content{
18
+ padding: 0 !important;
19
+ }
17
20
  .vtx_gmap_html_pointCollection_a{
18
21
  position: absolute;
19
22
  top: 0px;
@@ -12,6 +12,8 @@ var _react = require('react');
12
12
 
13
13
  var _react2 = _interopRequireDefault(_react);
14
14
 
15
+ var _reactDom = require('react-dom');
16
+
15
17
  require('./Map.css');
16
18
 
17
19
  var _MapToolFunction = require('../MapToolFunction');
@@ -20,6 +22,10 @@ var _immutable = require('immutable');
20
22
 
21
23
  var _immutable2 = _interopRequireDefault(_immutable);
22
24
 
25
+ var _unionBy = require('lodash/unionBy');
26
+
27
+ var _unionBy2 = _interopRequireDefault(_unionBy);
28
+
23
29
  var _default = require('../../default');
24
30
 
25
31
  var _default2 = _interopRequireDefault(_default);
@@ -214,6 +220,7 @@ var BaiduMap = function (_React$Component) {
214
220
  var _props2 = this.props,
215
221
  boundaryName = _props2.boundaryName,
216
222
  heatMapData = _props2.heatMapData,
223
+ infoWindowData = _props2.infoWindowData,
217
224
  customizedBoundary = _props2.customizedBoundary;
218
225
  var _state = this.state,
219
226
  boundaryInfo = _state.boundaryInfo,
@@ -254,6 +261,10 @@ var BaiduMap = function (_React$Component) {
254
261
  if (heatMapData) {
255
262
  t.heatMapOverlay(heatMapData);
256
263
  }
264
+ // 打开信息窗体
265
+ if (infoWindowData) {
266
+ t.infoWindow(infoWindowData);
267
+ }
257
268
  if (mapPointCollection instanceof Array) {
258
269
  t.addPointCollection(mapPointCollection);
259
270
  }
@@ -1242,12 +1253,17 @@ var BaiduMap = function (_React$Component) {
1242
1253
  var t = this;
1243
1254
  bdNames.forEach(function (name) {
1244
1255
  t._boundary.get(name, function (ary) {
1245
- var id = 'boundary' + new Date().getTime();
1246
- var paths = ary.boundaries[0].split(';').map(function (item, index) {
1247
- return item.split(',');
1256
+ // fix 飞地有多个区域的问题
1257
+ var arr = [];
1258
+ ary.boundaries.forEach(function (item) {
1259
+ var id = 'boundary' + new Date().getTime() + Math.random();
1260
+ var paths = item.split(';').map(function (item, index) {
1261
+ return item.split(',');
1262
+ });
1263
+ arr.push({ id: id, rings: paths, name: name });
1264
+ t.state.boundaryInfo.push({ id: id, name: name });
1248
1265
  });
1249
- t.addPolygon([{ id: id, rings: paths }]);
1250
- t.state.boundaryInfo.push({ id: id, name: name });
1266
+ t.addPolygon(arr);
1251
1267
  });
1252
1268
  });
1253
1269
  }
@@ -1312,6 +1328,34 @@ var BaiduMap = function (_React$Component) {
1312
1328
  t.heatmap.hide();
1313
1329
  }
1314
1330
  }
1331
+ //信息窗体
1332
+
1333
+ }, {
1334
+ key: 'infoWindow',
1335
+ value: function infoWindow() {
1336
+ var d = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1337
+
1338
+ var t = this;
1339
+ var cg = {
1340
+ width: 300,
1341
+ height: 172
1342
+ };
1343
+ if (d.config) {
1344
+ cg = _extends({}, cg, d.config);
1345
+ }
1346
+ var sContent = document.createElement('div');
1347
+ var infowindow = new BMap.InfoWindow(sContent);
1348
+
1349
+ infowindow.setWidth(cg.width);
1350
+ infowindow.setHeight(cg.height);
1351
+
1352
+ if (d.lat && d.lng && d.content) {
1353
+ (0, _reactDom.render)(d.content, sContent);
1354
+ t.state.gis.openInfoWindow(infowindow, new BMap.Point(d.lng, d.lat));
1355
+ } else {
1356
+ infowindow && t.state.gis.closeInfoWindow();
1357
+ }
1358
+ }
1315
1359
  //添加海量点
1316
1360
 
1317
1361
  }, {
@@ -1770,7 +1814,10 @@ var BaiduMap = function (_React$Component) {
1770
1814
  });
1771
1815
  break;
1772
1816
  case 'polygon':
1773
- pts = gg.getPath().map(function (item, index) {
1817
+ // fix: 编辑图元时面积计算不正确,需要过滤一下重复的经纬度
1818
+ pts = (0, _unionBy2.default)(gg.getPath(), function (res) {
1819
+ return res.lng && res.lat;
1820
+ }).map(function (item) {
1774
1821
  return [item.lng, item.lat];
1775
1822
  });
1776
1823
  p = _extends({}, gp, {
@@ -1913,7 +1960,11 @@ var BaiduMap = function (_React$Component) {
1913
1960
  geometry: param.geometry
1914
1961
  };
1915
1962
  if (param.geometry.type == 'polygon') {
1916
- obj.area = BMapLib.GeoUtils.getPolygonArea(param.mapLayer);
1963
+ // obj.area = BMapLib.GeoUtils.getPolygonArea(param.mapLayer);
1964
+ // fix: 只能是数组计算之前的计算因为重复的经纬度导致面积为NAN
1965
+ obj.area = BMapLib.GeoUtils.getPolygonArea(param.geometry.rings.map(function (item) {
1966
+ return new BMap.Point(item[0], item[1]);
1967
+ }));
1917
1968
  }
1918
1969
  if (param.geometry.type == 'polyline') {
1919
1970
  obj.distance = t.calculateDistance(param.geometry.paths);
@@ -2752,7 +2803,8 @@ var BaiduMap = function (_React$Component) {
2752
2803
  isClearAreaRestriction = nextProps.isClearAreaRestriction,
2753
2804
  isClearAll = nextProps.isClearAll,
2754
2805
  mapStyle = nextProps.mapStyle,
2755
- coverageType = nextProps.coverageType;
2806
+ coverageType = nextProps.coverageType,
2807
+ infoWindowData = nextProps.infoWindowData;
2756
2808
 
2757
2809
  var props = t.props;
2758
2810
 
@@ -3082,6 +3134,10 @@ var BaiduMap = function (_React$Component) {
3082
3134
  if (heatMapData && !t.deepEqual(heatMapData, props.heatMapData)) {
3083
3135
  t.heatMapOverlay(heatMapData);
3084
3136
  }
3137
+ // 打开信息窗体
3138
+ if (infoWindowData && !t.deepEqual(infoWindowData, props.infoWindowData)) {
3139
+ t.infoWindow(infoWindowData);
3140
+ }
3085
3141
  //添加图片图层
3086
3142
  if (imageOverlays instanceof Array && props.imageOverlays instanceof Array && !t.deepEqual(imageOverlays, props.imageOverlays)) {
3087
3143
  t.imageUrlOverlay(imageOverlays);
@@ -24,3 +24,9 @@
24
24
  .vtx_tmap_heatmap_class canvas {
25
25
  z-index: 400 !important;
26
26
  }
27
+ .tdt-infowindow-content {
28
+ margin: 0 !important;
29
+ }
30
+ .tdt-container a.tdt-infowindow-close-button {
31
+ z-index: 999;
32
+ }
@@ -12,6 +12,8 @@ var _react = require('react');
12
12
 
13
13
  var _react2 = _interopRequireDefault(_react);
14
14
 
15
+ var _reactDom = require('react-dom');
16
+
15
17
  require('./TMap.css');
16
18
 
17
19
  var _MapToolFunction = require('../MapToolFunction');
@@ -164,7 +166,8 @@ var TMap = function (_React$Component) {
164
166
  areaRestriction = _t$props.areaRestriction,
165
167
  heatMapData = _t$props.heatMapData,
166
168
  imageOverlays = _t$props.imageOverlays,
167
- coverageType = _t$props.coverageType;
169
+ coverageType = _t$props.coverageType,
170
+ infoWindowData = _t$props.infoWindowData;
168
171
  //创建地图
169
172
 
170
173
  t.createMap();
@@ -200,6 +203,10 @@ var TMap = function (_React$Component) {
200
203
  if (heatMapData) {
201
204
  t.heatMapOverlay(heatMapData);
202
205
  }
206
+ // 打开信息窗体
207
+ if (infoWindowData) {
208
+ t.infoWindow(infoWindowData);
209
+ }
203
210
  //添加海量点
204
211
  if (mapPointCollection instanceof Array) {
205
212
  setTimeout(function () {
@@ -461,24 +468,25 @@ var TMap = function (_React$Component) {
461
468
  ids = obj.fitView.split(',');
462
469
  }
463
470
  if (ids[0] instanceof Array) {
464
- for (var i = 0; i < ids.length; i++) {
465
- ls = new T.LngLat(ids[i][0], ids[i][1]);
466
- }
471
+ ls = ids.map(function (item) {
472
+ return new T.LngLat(item[0], item[1]);
473
+ });
467
474
  } else {
468
475
  ls = getLngLats(ids);
469
476
  }
470
477
  break;
471
478
  }
472
479
  if (ls.length >= 1) {
480
+ var _t$state$gis$getViewp = t.state.gis.getViewport(ls),
481
+ center = _t$state$gis$getViewp.center,
482
+ zoom = _t$state$gis$getViewp.zoom;
483
+
473
484
  if (obj.type == 'zoom') {
474
- t.setZoomLevel(t.state.gis.getViewport(ls).zoom);
485
+ t.setZoomLevel(zoom);
475
486
  } else if (obj.type == 'center') {
476
- var _t$state$gis$getViewp = t.state.gis.getViewport(ls),
477
- center = _t$state$gis$getViewp.center;
478
-
479
487
  t.setCenter([center.lng, center.lat]);
480
488
  } else {
481
- t.state.gis.setViewport(ls);
489
+ t.state.gis.centerAndZoom(center, zoom);
482
490
  }
483
491
  }
484
492
  }
@@ -1551,6 +1559,34 @@ var TMap = function (_React$Component) {
1551
1559
  t.heatmap.hide();
1552
1560
  }
1553
1561
  }
1562
+ //信息窗体
1563
+
1564
+ }, {
1565
+ key: 'infoWindow',
1566
+ value: function infoWindow() {
1567
+ var d = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1568
+
1569
+ var t = this;
1570
+ var cg = {
1571
+ width: 300,
1572
+ height: 172
1573
+ };
1574
+ if (d.config) {
1575
+ cg = _extends({}, cg, d.config);
1576
+ }
1577
+ var sContent = document.createElement('div');
1578
+ var infowindow = new T.InfoWindow();
1579
+ infowindow.setMinWidth(cg.width);
1580
+ infowindow.setMaxHeight(cg.height);
1581
+
1582
+ if (d.lat && d.lng && d.content) {
1583
+ (0, _reactDom.render)(d.content, sContent);
1584
+ infowindow.setContent(sContent);
1585
+ t.state.gis.openInfoWindow(infowindow, new T.LngLat(d.lng, d.lat));
1586
+ } else {
1587
+ infowindow && t.state.gis.closeInfoWindow();
1588
+ }
1589
+ }
1554
1590
  /*
1555
1591
  参数
1556
1592
  geometryType:point/polyline/polygon/circle/rectangle 默认point
@@ -2729,7 +2765,8 @@ var TMap = function (_React$Component) {
2729
2765
  isSetAreaRestriction = nextProps.isSetAreaRestriction,
2730
2766
  areaRestriction = nextProps.areaRestriction,
2731
2767
  isClearAreaRestriction = nextProps.isClearAreaRestriction,
2732
- coverageType = nextProps.coverageType;
2768
+ coverageType = nextProps.coverageType,
2769
+ infoWindowData = nextProps.infoWindowData;
2733
2770
 
2734
2771
  // 等待地图加载
2735
2772
 
@@ -3057,6 +3094,10 @@ var TMap = function (_React$Component) {
3057
3094
  if (heatMapData && !t.deepEqual(heatMapData, t.props.heatMapData)) {
3058
3095
  t.heatMapOverlay(heatMapData);
3059
3096
  }
3097
+ // 打开信息窗体
3098
+ if (infoWindowData && !t.deepEqual(infoWindowData, t.props.infoWindowData)) {
3099
+ t.infoWindow(infoWindowData);
3100
+ }
3060
3101
  //添加图片图层
3061
3102
  if (imageOverlays instanceof Array && !t.deepEqual(imageOverlays, t.props.imageOverlays)) {
3062
3103
  t.imageUrlOverlay(imageOverlays);
@@ -28,4 +28,10 @@
28
28
  z-index: 400 !important;
29
29
  }
30
30
  }
31
-
31
+
32
+ .tdt-infowindow-content{
33
+ margin: 0 !important;
34
+ }
35
+ .tdt-container a.tdt-infowindow-close-button{
36
+ z-index: 999;
37
+ }
@@ -253,7 +253,8 @@ var VtxSearchMap = function (_React$Component) {
253
253
  var lglt = this.map.getMapExtent(),
254
254
  editGraphic = null,
255
255
  editGraphicId = 'locationPoint';
256
- if (this.props.editParam && (this.props.graphicType == 'polyline' || this.props.graphicType == 'polygon')) {
256
+ if (this.props.editParam) {
257
+ // && (this.props.graphicType == 'polyline' || this.props.graphicType == 'polygon')
257
258
  editGraphic = _extends({}, this.props.editParam, { id: 'drawnGraph' });
258
259
  editGraphicId = 'drawnGraph';
259
260
  }
@@ -574,6 +575,18 @@ var VtxSearchMap = function (_React$Component) {
574
575
  drawProps = null;
575
576
  }
576
577
  }
578
+ if (graphicType === 'rectangle') {
579
+ if (editGraphic) {
580
+ mapPolygons.push(editGraphic);
581
+ drawProps = null;
582
+ }
583
+ }
584
+ if (graphicType === 'circle') {
585
+ if (editGraphic) {
586
+ mapCircles.push(editGraphic);
587
+ drawProps = null;
588
+ }
589
+ }
577
590
  if (isShowOtherGraph) {
578
591
  var otherGraph = this.props.otherGraph;
579
592
 
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@vtx/map",
3
- "version": "1.0.8",
3
+ "version": "1.1.1",
4
4
  "description": "@vtx/map",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
7
+ "docs:dev": "dumi dev",
8
+ "docs:build": "dumi build",
7
9
  "build": "rimraf lib && babel src --out-dir lib && node styleProcessor.js",
8
10
  "prepublish": "npm run build"
9
11
  },
@@ -26,13 +28,14 @@
26
28
  "babel-preset-es2015": "^6.24.1",
27
29
  "babel-preset-react": "^6.24.1",
28
30
  "babel-preset-stage-0": "^6.24.1",
31
+ "dumi": "^1.1.40",
29
32
  "less": "^3.9.0",
30
33
  "rimraf": "^2.6.2"
31
34
  },
32
35
  "peerDependencies": {
36
+ "antd": "3.26.19",
33
37
  "react": "^16.12.0",
34
- "react-dom": "^16.12.0",
35
- "antd": "3.26.19"
38
+ "react-dom": "^16.12.0"
36
39
  },
37
40
  "author": "ztq",
38
41
  "license": "MIT"