@vtx/map 1.1.0 → 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.
@@ -22,6 +22,10 @@ var _immutable = require('immutable');
22
22
 
23
23
  var _immutable2 = _interopRequireDefault(_immutable);
24
24
 
25
+ var _unionBy = require('lodash/unionBy');
26
+
27
+ var _unionBy2 = _interopRequireDefault(_unionBy);
28
+
25
29
  var _default = require('../../default');
26
30
 
27
31
  var _default2 = _interopRequireDefault(_default);
@@ -1810,7 +1814,10 @@ var BaiduMap = function (_React$Component) {
1810
1814
  });
1811
1815
  break;
1812
1816
  case 'polygon':
1813
- 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) {
1814
1821
  return [item.lng, item.lat];
1815
1822
  });
1816
1823
  p = _extends({}, gp, {
@@ -1953,7 +1960,11 @@ var BaiduMap = function (_React$Component) {
1953
1960
  geometry: param.geometry
1954
1961
  };
1955
1962
  if (param.geometry.type == 'polygon') {
1956
- 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
+ }));
1957
1968
  }
1958
1969
  if (param.geometry.type == 'polyline') {
1959
1970
  obj.distance = t.calculateDistance(param.geometry.paths);
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtx/map",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "@vtx/map",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {