@vtx/map 1.0.9 → 1.1.2

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.
package/README.md CHANGED
@@ -1,44 +1,44 @@
1
- # map
2
-
3
- > 地图控件
4
-
5
- ## 安装
6
-
7
- ```bash
8
- # Install
9
- $ npm install @vtx/map
10
- #或者
11
- $ yarn add @vtx/map
12
- ```
13
-
14
- ## 文档
15
-
16
- - [VtxMap](/docs/VtxMap.md)
17
- - [MapPlayer](/docs/MapPlayer.md)
18
- - [VtxSearchMap](/docs/VtxSearchMap.md)
19
- - [VtxOptMap](/docs/VtxOptMap.md)
20
-
21
- ### 全量导入引用方式(==不推荐==):
22
-
23
- ```js
24
- # 地图组件(地图组件的ref函数现在改为getMapInstance)
25
- $ import { VtxMap, VtxOptMap, VtxZoomMap } from '@vtx/map';
26
-
27
- # 地图弹出框组件
28
- $ import { VtxSearchMap } from '@vtx/map';
29
- ```
30
-
31
- ### 使用 babel-plugin-import 动态加载引用方式(==推荐==):
32
-
33
- ```js
34
- # 地图组件(地图组件的ref函数现在改为getMapInstance)
35
- $ import { VtxMap } from '@vtx/map';
36
- $ const { VtxOptMap, VtxZoomMap, MapPlayer } = VtxMap;
37
-
38
- # 地图弹出框组件
39
- $ import { VtxSearchMap } from '@vtx/map';
40
- ```
41
-
42
- ## License
43
-
44
- [MIT](https://tldrlegal.com/license/mit-license)
1
+ # map
2
+
3
+ > 地图控件
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ # Install
9
+ $ npm install @vtx/map
10
+ #或者
11
+ $ yarn add @vtx/map
12
+ ```
13
+
14
+ ## 文档
15
+
16
+ - [VtxMap](/docs/VtxMap.md)
17
+ - [MapPlayer](/docs/MapPlayer.md)
18
+ - [VtxSearchMap](/docs/VtxSearchMap.md)
19
+ - [VtxOptMap](/docs/VtxOptMap.md)
20
+
21
+ ### 全量导入引用方式(==不推荐==):
22
+
23
+ ```js
24
+ # 地图组件(地图组件的ref函数现在改为getMapInstance)
25
+ $ import { VtxMap, VtxOptMap, VtxZoomMap } from '@vtx/map';
26
+
27
+ # 地图弹出框组件
28
+ $ import { VtxSearchMap } from '@vtx/map';
29
+ ```
30
+
31
+ ### 使用 babel-plugin-import 动态加载引用方式(==推荐==):
32
+
33
+ ```js
34
+ # 地图组件(地图组件的ref函数现在改为getMapInstance)
35
+ $ import { VtxMap } from '@vtx/map';
36
+ $ const { VtxOptMap, VtxZoomMap, MapPlayer } = VtxMap;
37
+
38
+ # 地图弹出框组件
39
+ $ import { VtxSearchMap } from '@vtx/map';
40
+ ```
41
+
42
+ ## License
43
+
44
+ [MIT](https://tldrlegal.com/license/mit-license)
@@ -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
  }
@@ -747,7 +760,8 @@ var VortexAMap = function (_React$Component) {
747
760
  value: function showControl(props) {
748
761
  var t = this,
749
762
  location = 'RT',
750
- offset = null;
763
+ offset = null,
764
+ scaleOffset = null;
751
765
  var config = props || t.props;
752
766
  if (t.scaleControl) {
753
767
  t.state.gis.removeControl(t.scaleControl);
@@ -1020,6 +1034,45 @@ var VortexAMap = function (_React$Component) {
1020
1034
  t.heatmap.hide();
1021
1035
  }
1022
1036
  }
1037
+ // 信息窗体
1038
+
1039
+ }, {
1040
+ key: 'infoWindow',
1041
+ value: function (_infoWindow) {
1042
+ function infoWindow() {
1043
+ return _infoWindow.apply(this, arguments);
1044
+ }
1045
+
1046
+ infoWindow.toString = function () {
1047
+ return _infoWindow.toString();
1048
+ };
1049
+
1050
+ return infoWindow;
1051
+ }(function () {
1052
+ var d = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1053
+
1054
+ var t = this;
1055
+ var cg = {
1056
+ width: 300,
1057
+ height: 172
1058
+ };
1059
+ if (d.config) {
1060
+ cg = _extends({}, cg, d.config);
1061
+ }
1062
+ var sContent = document.createElement('div');
1063
+ var infowindow = new AMap.InfoWindow({
1064
+ // isCustom: true,
1065
+ content: sContent
1066
+ });
1067
+ infowindow.setSize(new AMap.Size(cg.width, cg.height + 20));
1068
+
1069
+ if (d.lat && d.lng && d.content) {
1070
+ (0, _reactDom.render)(d.content, sContent);
1071
+ infowindow.open(t.state.gis, [d.lng, d.lat]);
1072
+ } else {
1073
+ infoWindow.close();
1074
+ }
1075
+ })
1023
1076
  //添加海量点
1024
1077
 
1025
1078
  }, {
@@ -2612,7 +2665,8 @@ var VortexAMap = function (_React$Component) {
2612
2665
  areaRestriction = nextProps.areaRestriction,
2613
2666
  isClearAreaRestriction = nextProps.isClearAreaRestriction,
2614
2667
  mapStyle = nextProps.mapStyle,
2615
- coverageType = nextProps.coverageType;
2668
+ coverageType = nextProps.coverageType,
2669
+ infoWindowData = nextProps.infoWindowData;
2616
2670
 
2617
2671
  var props = t.props;
2618
2672
  // 设置地图样式
@@ -2934,6 +2988,10 @@ var VortexAMap = function (_React$Component) {
2934
2988
  if (heatMapData && !t.deepEqual(heatMapData, props.heatMapData)) {
2935
2989
  t.heatMapOverlay(heatMapData);
2936
2990
  }
2991
+ // 打开信息窗体
2992
+ if (infoWindowData && !t.deepEqual(infoWindowData, t.props.infoWindowData)) {
2993
+ t.infoWindow(infoWindowData);
2994
+ }
2937
2995
  //添加图片图层
2938
2996
  if (imageOverlays instanceof Array && props.imageOverlays instanceof Array && !t.deepEqual(imageOverlays, props.imageOverlays)) {
2939
2997
  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,6 +1253,7 @@ var BaiduMap = function (_React$Component) {
1242
1253
  var t = this;
1243
1254
  bdNames.forEach(function (name) {
1244
1255
  t._boundary.get(name, function (ary) {
1256
+ // fix 飞地有多个区域的问题
1245
1257
  var arr = [];
1246
1258
  ary.boundaries.forEach(function (item) {
1247
1259
  var id = 'boundary' + new Date().getTime() + Math.random();
@@ -1316,6 +1328,34 @@ var BaiduMap = function (_React$Component) {
1316
1328
  t.heatmap.hide();
1317
1329
  }
1318
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
+ }
1319
1359
  //添加海量点
1320
1360
 
1321
1361
  }, {
@@ -1774,7 +1814,10 @@ var BaiduMap = function (_React$Component) {
1774
1814
  });
1775
1815
  break;
1776
1816
  case 'polygon':
1777
- 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) {
1778
1821
  return [item.lng, item.lat];
1779
1822
  });
1780
1823
  p = _extends({}, gp, {
@@ -1917,7 +1960,11 @@ var BaiduMap = function (_React$Component) {
1917
1960
  geometry: param.geometry
1918
1961
  };
1919
1962
  if (param.geometry.type == 'polygon') {
1920
- 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
+ }));
1921
1968
  }
1922
1969
  if (param.geometry.type == 'polyline') {
1923
1970
  obj.distance = t.calculateDistance(param.geometry.paths);
@@ -2756,7 +2803,8 @@ var BaiduMap = function (_React$Component) {
2756
2803
  isClearAreaRestriction = nextProps.isClearAreaRestriction,
2757
2804
  isClearAll = nextProps.isClearAll,
2758
2805
  mapStyle = nextProps.mapStyle,
2759
- coverageType = nextProps.coverageType;
2806
+ coverageType = nextProps.coverageType,
2807
+ infoWindowData = nextProps.infoWindowData;
2760
2808
 
2761
2809
  var props = t.props;
2762
2810
 
@@ -3086,6 +3134,10 @@ var BaiduMap = function (_React$Component) {
3086
3134
  if (heatMapData && !t.deepEqual(heatMapData, props.heatMapData)) {
3087
3135
  t.heatMapOverlay(heatMapData);
3088
3136
  }
3137
+ // 打开信息窗体
3138
+ if (infoWindowData && !t.deepEqual(infoWindowData, props.infoWindowData)) {
3139
+ t.infoWindow(infoWindowData);
3140
+ }
3089
3141
  //添加图片图层
3090
3142
  if (imageOverlays instanceof Array && props.imageOverlays instanceof Array && !t.deepEqual(imageOverlays, props.imageOverlays)) {
3091
3143
  t.imageUrlOverlay(imageOverlays);
@@ -301,8 +301,8 @@ var Map = function (_React$Component) {
301
301
  }
302
302
  });
303
303
  /*=================================start========================================*/
304
- /*
305
- draw对象声明, 绘制返回方法实现
304
+ /*
305
+ draw对象声明, 绘制返回方法实现
306
306
  */
307
307
  if (!t._drawmanager) {
308
308
  t._drawmanager = new google.maps.drawing.DrawingManager({
@@ -316,9 +316,9 @@ var Map = function (_React$Component) {
316
316
  t._cluster = new OMapLib.MarkerClusterer(map, [], { maxZoom: options.maxZoom });
317
317
  }
318
318
  /*=================================start========================================*/
319
- /*
320
- 声明OverlayView 类
321
- 用于切换lnglat和 pixel
319
+ /*
320
+ 声明OverlayView 类
321
+ 用于切换lnglat和 pixel
322
322
  */
323
323
  function CanvasProjectionOverlay() {}
324
324
  CanvasProjectionOverlay.prototype = new google.maps.OverlayView();
@@ -329,9 +329,9 @@ var Map = function (_React$Component) {
329
329
  this.canvasProjectionOverlay = new CanvasProjectionOverlay();
330
330
  this.canvasProjectionOverlay.setMap(map);
331
331
  /*=================================start========================================*/
332
- /*
333
- 重写marker对象,支持html
334
- 要使用google对象,所以在creatMap中声明
332
+ /*
333
+ 重写marker对象,支持html
334
+ 要使用google对象,所以在creatMap中声明
335
335
  */
336
336
  var MyLabel = t.MyLabel = function (map) {
337
337
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -725,7 +725,7 @@ var Map = function (_React$Component) {
725
725
  var position = new t.omap.LatLng({ lng: item.longitude, lat: item.latitude });
726
726
  var marker = null;
727
727
  if (item.markerContent) {
728
- /*自定义html加点
728
+ /*自定义html加点
729
729
  用Label来实现,无法再添加label(高德有判断,实现不同)*/
730
730
  //覆盖物参数
731
731
  marker = new t.MyLabel(t.state.gis, {
@@ -747,9 +747,9 @@ var Map = function (_React$Component) {
747
747
  isLabel: true,
748
748
  labelClass: labelClass,
749
749
  labelContent: cg.labelContent,
750
- /*
751
- 为和百度等地图相同的参数 加上g.markerContentY值
752
- label是使用OverlayView手动实现,与marker没有关联的原因
750
+ /*
751
+ 为和百度等地图相同的参数 加上g.markerContentY值
752
+ label是使用OverlayView手动实现,与marker没有关联的原因
753
753
  */
754
754
  labelOffset: { x: cg.labelPixelX, y: cg.labelPixelY + cg.markerContentY }
755
755
  });
@@ -904,9 +904,9 @@ var Map = function (_React$Component) {
904
904
  var oldPosition = gc.getPosition();
905
905
  //前后点位类型都是markerContent
906
906
  if (gc.isMarkerContent && gc.isMarkerContent() && item.markerContent) {
907
- /*
908
- 自定义html加点
909
- 用Label来实现,无法再添加label(高德有判断,实现不同)
907
+ /*
908
+ 自定义html加点
909
+ 用Label来实现,无法再添加label(高德有判断,实现不同)
910
910
  */
911
911
  //覆盖物参数
912
912
  gc.setOptions({
@@ -960,9 +960,9 @@ var Map = function (_React$Component) {
960
960
  gc_label.setOptions({
961
961
  labelClass: labelClass,
962
962
  labelContent: cg.labelContent,
963
- /*
964
- 为和百度等地图相同的参数 加上g.markerContentY值
965
- label是使用OverlayView手动实现,与marker没有关联的原因
963
+ /*
964
+ 为和百度等地图相同的参数 加上g.markerContentY值
965
+ label是使用OverlayView手动实现,与marker没有关联的原因
966
966
  */
967
967
  labelOffset: { x: cg.labelPixelX, y: cg.labelPixelY + cg.markerContentY }
968
968
  });
@@ -1072,9 +1072,9 @@ var Map = function (_React$Component) {
1072
1072
  gc_label.setOptions({
1073
1073
  labelClass: _labelClass,
1074
1074
  labelContent: cg.labelContent,
1075
- /*
1076
- 为和百度等地图相同的参数 加上g.markerContentY值
1077
- label是使用OverlayView手动实现,与marker没有关联的原因
1075
+ /*
1076
+ 为和百度等地图相同的参数 加上g.markerContentY值
1077
+ label是使用OverlayView手动实现,与marker没有关联的原因
1078
1078
  */
1079
1079
  labelOffset: { x: cg.labelPixelX, y: cg.labelPixelY + cg.markerContentY }
1080
1080
  });
@@ -2396,8 +2396,8 @@ var Map = function (_React$Component) {
2396
2396
  var t = this;
2397
2397
  t._drawmanager.setDrawingMode(null);
2398
2398
  }
2399
- /*
2400
- 事件处理
2399
+ /*
2400
+ 事件处理
2401
2401
  */
2402
2402
  //点击图元事件
2403
2403
 
@@ -2482,8 +2482,8 @@ var Map = function (_React$Component) {
2482
2482
  t.props.mouseOutGraphic(obj);
2483
2483
  }
2484
2484
  }
2485
- /*
2486
- 地图服务功能
2485
+ /*
2486
+ 地图服务功能
2487
2487
  */
2488
2488
  //开启路况
2489
2489
 
@@ -3319,9 +3319,9 @@ var Map = function (_React$Component) {
3319
3319
  }
3320
3320
  return deg;
3321
3321
  }
3322
- /*
3323
- 匹配控件位置方法
3324
- (谷歌地图有8个方位,为了统一,只使用左上,左下,右上,右下)
3322
+ /*
3323
+ 匹配控件位置方法
3324
+ (谷歌地图有8个方位,为了统一,只使用左上,左下,右上,右下)
3325
3325
  */
3326
3326
 
3327
3327
  }, {
@@ -3344,8 +3344,8 @@ var Map = function (_React$Component) {
3344
3344
  }
3345
3345
  return position;
3346
3346
  }
3347
- /*
3348
- 地图内部需要公共方法
3347
+ /*
3348
+ 地图内部需要公共方法
3349
3349
  */
3350
3350
 
3351
3351
  }, {
@@ -3560,10 +3560,10 @@ var Map = function (_React$Component) {
3560
3560
  if (typeof isclearAllPointCollection == 'boolean' && isclearAllPointCollection || isclearAllPointCollection && isclearAllPointCollection !== t.props.isclearAllPointCollection) {
3561
3561
  t.clearAllPointCollection();
3562
3562
  }
3563
- /*点数据处理
3564
- pointData[2]相同的点,执行刷新
3565
- pointData[1]的数据在idsForGraphicId中不存在的,执行新增
3566
- pointData[0]数据中多余的id,执行删除
3563
+ /*点数据处理
3564
+ pointData[2]相同的点,执行刷新
3565
+ pointData[1]的数据在idsForGraphicId中不存在的,执行新增
3566
+ pointData[0]数据中多余的id,执行删除
3567
3567
  */
3568
3568
  if (mapPoints instanceof Array && props.mapPoints instanceof Array && !t.deepEqual(mapPoints, props.mapPoints)) {
3569
3569
  var oldMapPoints = props.mapPoints;
@@ -3623,9 +3623,9 @@ var Map = function (_React$Component) {
3623
3623
  //更新
3624
3624
  t.updatePoint([].concat(_toConsumableArray(upds), _toConsumableArray(otherupds)));
3625
3625
  }
3626
- /*
3627
- 面数据处理
3628
- 先全删除,再新增
3626
+ /*
3627
+ 面数据处理
3628
+ 先全删除,再新增
3629
3629
  */
3630
3630
  if (mapPolygons instanceof Array && props.mapPolygons instanceof Array && !t.deepEqual(mapPolygons, props.mapPolygons)) {
3631
3631
  var oldMapPolygons = props.mapPolygons;
@@ -3684,9 +3684,9 @@ var Map = function (_React$Component) {
3684
3684
  //更新
3685
3685
  t.updatePolygon([].concat(_toConsumableArray(_upds), _toConsumableArray(_otherupds)));
3686
3686
  }
3687
- /*
3688
- 圆数据处理
3689
- 先全删除,再新增
3687
+ /*
3688
+ 圆数据处理
3689
+ 先全删除,再新增
3690
3690
  */
3691
3691
  if (mapCircles instanceof Array && props.mapCircles instanceof Array && !t.deepEqual(mapCircles, props.mapCircles)) {
3692
3692
  var oldMapCircles = props.mapCircles;
@@ -3745,9 +3745,9 @@ var Map = function (_React$Component) {
3745
3745
  //更新
3746
3746
  t.updateCircle([].concat(_toConsumableArray(_upds2), _toConsumableArray(_otherupds2)));
3747
3747
  }
3748
- /*
3749
- 线数据处理
3750
- 先全删除,再新增
3748
+ /*
3749
+ 线数据处理
3750
+ 先全删除,再新增
3751
3751
  */
3752
3752
  if (mapLines instanceof Array && props.mapLines instanceof Array && !t.deepEqual(mapLines, props.mapLines)) {
3753
3753
  var oldMapLines = props.mapLines;
@@ -1,70 +1,70 @@
1
- .label-content{
2
- display: inline-block;
3
- padding: 5px;
4
- line-height: 22px;
5
- text-align: center;
6
- border-radius: 5px;
7
- background-color: #fff;
8
- opacity: 1;
9
- color: #5DD0EE;
10
- transform: translate(-50%);
11
- -ms-transform: translate(-50%);
12
- }
13
- .noselect {
14
- -webkit-touch-callout: none; /* iOS Safari */
15
- -webkit-user-select: none; /* Chrome/Safari/Opera */
16
- -khtml-user-select: none; /* Konqueror */
17
- -moz-user-select: none; /* Firefox */
18
- -ms-user-select: none; /* Internet Explorer/Edge */
19
- user-select: none; /* Non-prefixed version, currently
20
- not supported by any browser */
21
- }
22
- .vtx_gmap_html_pointCollection_a{
23
- position: absolute;
24
- canvas{
25
- z-index: 111;
26
- }
27
- }
28
- .vtx-g-rangingPoint{
29
- width: 8px;
30
- height: 8px;
31
- background-color: #fff;
32
- border: 2px solid #108ee9;
33
- display: inline-block;
34
- border-radius: 8px;
35
- position: relative;
36
- top: 5px;
37
- left: 1px;
38
- }
39
- .vtx-g-rangingDistance{
40
- position: relative;
41
- top: -36px;
42
- left: 15px;
43
- height: 30px;
44
- line-height: 28px;
45
- background-color: #fff;
46
- border: 1px solid #108ee9;
47
- font-size: 12px;
48
- word-break: keep-all;
49
- padding: 0px 3px;
50
- color: #108ee9;
51
- }
52
- .vtx-g-rang-exit{
53
- width: 12px;
54
- height: 12px;
55
- background-color: #fff;
56
- border: 2px solid #108ee9;
57
- color: #108ee9;
58
- line-height: 7px;
59
- text-align: center;
60
- font-size: 12px;
61
- cursor: pointer;
62
- }
63
- .vtx-g-rang-showRangTool{
64
- line-height: 18px;
65
- font-size: 12px;
66
- border: 1px solid #108ee9;
67
- word-break: keep-all;
68
- background-color: #fff;
69
- padding: 0px 5px;
70
- }
1
+ .label-content{
2
+ display: inline-block;
3
+ padding: 5px;
4
+ line-height: 22px;
5
+ text-align: center;
6
+ border-radius: 5px;
7
+ background-color: #fff;
8
+ opacity: 1;
9
+ color: #5DD0EE;
10
+ transform: translate(-50%);
11
+ -ms-transform: translate(-50%);
12
+ }
13
+ .noselect {
14
+ -webkit-touch-callout: none; /* iOS Safari */
15
+ -webkit-user-select: none; /* Chrome/Safari/Opera */
16
+ -khtml-user-select: none; /* Konqueror */
17
+ -moz-user-select: none; /* Firefox */
18
+ -ms-user-select: none; /* Internet Explorer/Edge */
19
+ user-select: none; /* Non-prefixed version, currently
20
+ not supported by any browser */
21
+ }
22
+ .vtx_gmap_html_pointCollection_a{
23
+ position: absolute;
24
+ canvas{
25
+ z-index: 111;
26
+ }
27
+ }
28
+ .vtx-g-rangingPoint{
29
+ width: 8px;
30
+ height: 8px;
31
+ background-color: #fff;
32
+ border: 2px solid #108ee9;
33
+ display: inline-block;
34
+ border-radius: 8px;
35
+ position: relative;
36
+ top: 5px;
37
+ left: 1px;
38
+ }
39
+ .vtx-g-rangingDistance{
40
+ position: relative;
41
+ top: -36px;
42
+ left: 15px;
43
+ height: 30px;
44
+ line-height: 28px;
45
+ background-color: #fff;
46
+ border: 1px solid #108ee9;
47
+ font-size: 12px;
48
+ word-break: keep-all;
49
+ padding: 0px 3px;
50
+ color: #108ee9;
51
+ }
52
+ .vtx-g-rang-exit{
53
+ width: 12px;
54
+ height: 12px;
55
+ background-color: #fff;
56
+ border: 2px solid #108ee9;
57
+ color: #108ee9;
58
+ line-height: 7px;
59
+ text-align: center;
60
+ font-size: 12px;
61
+ cursor: pointer;
62
+ }
63
+ .vtx-g-rang-showRangTool{
64
+ line-height: 18px;
65
+ font-size: 12px;
66
+ border: 1px solid #108ee9;
67
+ word-break: keep-all;
68
+ background-color: #fff;
69
+ padding: 0px 5px;
70
+ }
@@ -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,11 +1559,39 @@ var TMap = function (_React$Component) {
1551
1559
  t.heatmap.hide();
1552
1560
  }
1553
1561
  }
1554
- /*
1555
- 参数
1556
- geometryType:point/polyline/polygon/circle/rectangle 默认point
1557
- parameter 样式 默认null 对象{}写入方式跟add方法一样(对应点线圆面)
1558
- data //初始化数据 默认{id:'add'}
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
+ }
1590
+ /*
1591
+ 参数
1592
+ geometryType:point/polyline/polygon/circle/rectangle 默认point
1593
+ parameter 样式 默认null 对象{}写入方式跟add方法一样(对应点线圆面)
1594
+ data //初始化数据 默认{id:'add'}
1559
1595
  */
1560
1596
 
1561
1597
  }, {
@@ -2017,7 +2053,8 @@ var TMap = function (_React$Component) {
2017
2053
  ms.geometry._extent = (0, _MapToolFunction.getMaxMin)(ms.mapLayer.getLngLats()[0])._extent;
2018
2054
  obj.geometry = ms.geometry;
2019
2055
  obj.param = ms;
2020
- obj.area = (0, _MapToolFunction.getPolygonArea)(ms.mapLayer.getLngLats()[0]);
2056
+ // obj.area = getPolygonArea(ms.mapLayer.getLngLats()[0]);
2057
+ obj.area = t.polygonTool.getArea(ms.mapLayer.getLngLats()[0]);
2021
2058
  break;
2022
2059
  case 'circle':
2023
2060
  obj.geometry = ms.geometry;
@@ -2729,7 +2766,8 @@ var TMap = function (_React$Component) {
2729
2766
  isSetAreaRestriction = nextProps.isSetAreaRestriction,
2730
2767
  areaRestriction = nextProps.areaRestriction,
2731
2768
  isClearAreaRestriction = nextProps.isClearAreaRestriction,
2732
- coverageType = nextProps.coverageType;
2769
+ coverageType = nextProps.coverageType,
2770
+ infoWindowData = nextProps.infoWindowData;
2733
2771
 
2734
2772
  // 等待地图加载
2735
2773
 
@@ -2761,10 +2799,10 @@ var TMap = function (_React$Component) {
2761
2799
  t.clearAllPointCollection();
2762
2800
  }
2763
2801
 
2764
- /*点数据处理
2765
- pointData[2]相同的点,执行刷新
2766
- pointData[1]的数据在idsForGraphicId中不存在的,执行新增
2767
- pointData[0]数据中多余的id,执行删除
2802
+ /*点数据处理
2803
+ pointData[2]相同的点,执行刷新
2804
+ pointData[1]的数据在idsForGraphicId中不存在的,执行新增
2805
+ pointData[0]数据中多余的id,执行删除
2768
2806
  */
2769
2807
  if (mapPoints instanceof Array && t.props.mapPoints instanceof Array && !t.deepEqual(mapPoints, t.props.mapPoints)) {
2770
2808
  var oldMapPoints = t.props.mapPoints;
@@ -2824,9 +2862,9 @@ var TMap = function (_React$Component) {
2824
2862
  //更新
2825
2863
  t.updatePoint([].concat(_toConsumableArray(upds), _toConsumableArray(otherupds)));
2826
2864
  }
2827
- /*
2828
- 面数据处理
2829
- 先全删除,再新增
2865
+ /*
2866
+ 面数据处理
2867
+ 先全删除,再新增
2830
2868
  */
2831
2869
  if (mapPolygons instanceof Array && t.props.mapPolygons instanceof Array && !t.deepEqual(mapPolygons, t.props.mapPolygons)) {
2832
2870
  var oldMapPolygons = t.props.mapPolygons;
@@ -2885,9 +2923,9 @@ var TMap = function (_React$Component) {
2885
2923
  //更新
2886
2924
  t.updatePolygon([].concat(_toConsumableArray(_upds), _toConsumableArray(_otherupds)));
2887
2925
  }
2888
- /*
2889
- 圆数据处理
2890
- 先全删除,再新增
2926
+ /*
2927
+ 圆数据处理
2928
+ 先全删除,再新增
2891
2929
  */
2892
2930
  if (mapCircles instanceof Array && t.props.mapCircles instanceof Array && !t.deepEqual(mapCircles, t.props.mapCircles)) {
2893
2931
  var oldMapCircles = t.props.mapCircles;
@@ -2946,9 +2984,9 @@ var TMap = function (_React$Component) {
2946
2984
  //更新
2947
2985
  t.updateCircle([].concat(_toConsumableArray(_upds2), _toConsumableArray(_otherupds2)));
2948
2986
  }
2949
- /*
2950
- 线数据处理
2951
- 先全删除,再新增
2987
+ /*
2988
+ 线数据处理
2989
+ 先全删除,再新增
2952
2990
  */
2953
2991
  if (mapLines instanceof Array && t.props.mapLines instanceof Array && !t.deepEqual(mapLines, t.props.mapLines)) {
2954
2992
  var oldMapLines = t.props.mapLines;
@@ -3057,6 +3095,10 @@ var TMap = function (_React$Component) {
3057
3095
  if (heatMapData && !t.deepEqual(heatMapData, t.props.heatMapData)) {
3058
3096
  t.heatMapOverlay(heatMapData);
3059
3097
  }
3098
+ // 打开信息窗体
3099
+ if (infoWindowData && !t.deepEqual(infoWindowData, t.props.infoWindowData)) {
3100
+ t.infoWindow(infoWindowData);
3101
+ }
3060
3102
  //添加图片图层
3061
3103
  if (imageOverlays instanceof Array && !t.deepEqual(imageOverlays, t.props.imageOverlays)) {
3062
3104
  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.9",
3
+ "version": "1.1.2",
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"