@vtx/map 1.0.9 → 1.1.0

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');
@@ -214,6 +216,7 @@ var BaiduMap = function (_React$Component) {
214
216
  var _props2 = this.props,
215
217
  boundaryName = _props2.boundaryName,
216
218
  heatMapData = _props2.heatMapData,
219
+ infoWindowData = _props2.infoWindowData,
217
220
  customizedBoundary = _props2.customizedBoundary;
218
221
  var _state = this.state,
219
222
  boundaryInfo = _state.boundaryInfo,
@@ -254,6 +257,10 @@ var BaiduMap = function (_React$Component) {
254
257
  if (heatMapData) {
255
258
  t.heatMapOverlay(heatMapData);
256
259
  }
260
+ // 打开信息窗体
261
+ if (infoWindowData) {
262
+ t.infoWindow(infoWindowData);
263
+ }
257
264
  if (mapPointCollection instanceof Array) {
258
265
  t.addPointCollection(mapPointCollection);
259
266
  }
@@ -1242,6 +1249,7 @@ var BaiduMap = function (_React$Component) {
1242
1249
  var t = this;
1243
1250
  bdNames.forEach(function (name) {
1244
1251
  t._boundary.get(name, function (ary) {
1252
+ // fix 飞地有多个区域的问题
1245
1253
  var arr = [];
1246
1254
  ary.boundaries.forEach(function (item) {
1247
1255
  var id = 'boundary' + new Date().getTime() + Math.random();
@@ -1316,6 +1324,34 @@ var BaiduMap = function (_React$Component) {
1316
1324
  t.heatmap.hide();
1317
1325
  }
1318
1326
  }
1327
+ //信息窗体
1328
+
1329
+ }, {
1330
+ key: 'infoWindow',
1331
+ value: function infoWindow() {
1332
+ var d = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1333
+
1334
+ var t = this;
1335
+ var cg = {
1336
+ width: 300,
1337
+ height: 172
1338
+ };
1339
+ if (d.config) {
1340
+ cg = _extends({}, cg, d.config);
1341
+ }
1342
+ var sContent = document.createElement('div');
1343
+ var infowindow = new BMap.InfoWindow(sContent);
1344
+
1345
+ infowindow.setWidth(cg.width);
1346
+ infowindow.setHeight(cg.height);
1347
+
1348
+ if (d.lat && d.lng && d.content) {
1349
+ (0, _reactDom.render)(d.content, sContent);
1350
+ t.state.gis.openInfoWindow(infowindow, new BMap.Point(d.lng, d.lat));
1351
+ } else {
1352
+ infowindow && t.state.gis.closeInfoWindow();
1353
+ }
1354
+ }
1319
1355
  //添加海量点
1320
1356
 
1321
1357
  }, {
@@ -2756,7 +2792,8 @@ var BaiduMap = function (_React$Component) {
2756
2792
  isClearAreaRestriction = nextProps.isClearAreaRestriction,
2757
2793
  isClearAll = nextProps.isClearAll,
2758
2794
  mapStyle = nextProps.mapStyle,
2759
- coverageType = nextProps.coverageType;
2795
+ coverageType = nextProps.coverageType,
2796
+ infoWindowData = nextProps.infoWindowData;
2760
2797
 
2761
2798
  var props = t.props;
2762
2799
 
@@ -3086,6 +3123,10 @@ var BaiduMap = function (_React$Component) {
3086
3123
  if (heatMapData && !t.deepEqual(heatMapData, props.heatMapData)) {
3087
3124
  t.heatMapOverlay(heatMapData);
3088
3125
  }
3126
+ // 打开信息窗体
3127
+ if (infoWindowData && !t.deepEqual(infoWindowData, props.infoWindowData)) {
3128
+ t.infoWindow(infoWindowData);
3129
+ }
3089
3130
  //添加图片图层
3090
3131
  if (imageOverlays instanceof Array && props.imageOverlays instanceof Array && !t.deepEqual(imageOverlays, props.imageOverlays)) {
3091
3132
  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
+ }
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@vtx/map",
3
- "version": "1.0.9",
3
+ "version": "1.1.0",
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"