@vtx/map 1.0.4 → 1.0.5
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/lib/VtxMap/AMap/AMap.js +67 -14
- package/lib/VtxMap/BMap/Map.js +37 -21
- package/lib/VtxMap/TMap/TMap.js +55 -12
- package/package.json +1 -1
package/lib/VtxMap/AMap/AMap.js
CHANGED
|
@@ -744,44 +744,88 @@ var VortexAMap = function (_React$Component) {
|
|
|
744
744
|
|
|
745
745
|
}, {
|
|
746
746
|
key: 'showControl',
|
|
747
|
-
value: function showControl() {
|
|
747
|
+
value: function showControl(props) {
|
|
748
748
|
var t = this,
|
|
749
749
|
location = 'RT',
|
|
750
750
|
offset = null;
|
|
751
|
-
|
|
752
|
-
if (t.
|
|
753
|
-
|
|
751
|
+
var config = props || t.props;
|
|
752
|
+
if (t.scaleControl) {
|
|
753
|
+
t.state.gis.removeControl(t.scaleControl);
|
|
754
|
+
}
|
|
755
|
+
if (t.navigationControl) {
|
|
756
|
+
t.state.gis.removeControl(t.navigationControl);
|
|
754
757
|
}
|
|
755
|
-
if (
|
|
756
|
-
|
|
757
|
-
|
|
758
|
+
if (config.showControl.location) {
|
|
759
|
+
location = t.AnchorConstant[config.showControl.location];
|
|
760
|
+
}
|
|
761
|
+
if (config.showControl.offset && config.showControl.offset.length > 0) {
|
|
762
|
+
offset = new AMap.Pixel(config.showControl.offset[0], config.showControl.offset[1]);
|
|
763
|
+
scaleOffset = new AMap.Pixel(config.showControl.offset[0] + 70, config.showControl.offset[1]);
|
|
758
764
|
}
|
|
759
765
|
// 添加比例尺
|
|
760
766
|
var control = new AMap.Scale({ position: location, offset: scaleOffset });
|
|
761
767
|
t.state.gis.addControl(control);
|
|
762
|
-
|
|
768
|
+
t.scaleControl = control;
|
|
763
769
|
// 包含平移和缩放按钮
|
|
764
770
|
var navigation = new AMap.ToolBar({ position: location, offset: offset });
|
|
765
771
|
t.state.gis.addControl(navigation);
|
|
772
|
+
t.navigationControl = navigation;
|
|
766
773
|
}
|
|
767
774
|
//展示地图切换控件
|
|
768
775
|
|
|
769
776
|
}, {
|
|
770
777
|
key: 'showMapTypeControl',
|
|
771
|
-
value: function showMapTypeControl() {
|
|
778
|
+
value: function showMapTypeControl(props) {
|
|
772
779
|
var t = this,
|
|
773
780
|
location = 'RT',
|
|
774
781
|
offset = null;
|
|
775
|
-
|
|
776
|
-
if (t.
|
|
777
|
-
|
|
782
|
+
var config = props || t.props;
|
|
783
|
+
if (t.mapTypeControl) {
|
|
784
|
+
t.state.gis.removeControl(t.mapTypeControl);
|
|
778
785
|
}
|
|
779
|
-
if (
|
|
780
|
-
|
|
786
|
+
if (config.satelliteSwitch.location) {
|
|
787
|
+
location = t.AnchorConstant[config.satelliteSwitch.location];
|
|
781
788
|
}
|
|
789
|
+
|
|
782
790
|
// 地图切换控件
|
|
783
791
|
var control = new AMap.MapType({ position: location, offset: offset });
|
|
784
792
|
t.state.gis.addControl(control);
|
|
793
|
+
t.mapTypeControl = control;
|
|
794
|
+
|
|
795
|
+
// TODO,MapType没有这些属性,所以下面定位和偏移不生效,手动修改
|
|
796
|
+
function reloaction() {
|
|
797
|
+
if (location == 'RT') {
|
|
798
|
+
$('div.amap-maptypecontrol').css({ right: 0, top: 0, left: 'inherit', bottom: 'inherit' });
|
|
799
|
+
} else if (location == 'LT') {
|
|
800
|
+
$('div.amap-maptypecontrol').css({ left: 0 + 64, top: 0, right: 'inherit', bottom: 'inherit' });
|
|
801
|
+
} else if (location == 'LB') {
|
|
802
|
+
$('div.amap-maptypecontrol').css({ left: 0 + 64, bottom: 0 + 84, right: 'inherit', top: 'inherit' });
|
|
803
|
+
} else if (location == 'RB') {
|
|
804
|
+
$('div.amap-maptypecontrol').css({ right: 0, bottom: 0 + 84, left: 'inherit', top: 'inherit' });
|
|
805
|
+
}
|
|
806
|
+
if (config.satelliteSwitch.offset && config.satelliteSwitch.offset.length > 0) {
|
|
807
|
+
if (location == 'RT') {
|
|
808
|
+
$('div.amap-maptypecontrol').css({ right: config.satelliteSwitch.offset[0], top: config.satelliteSwitch.offset[1], left: 'inherit', bottom: 'inherit' });
|
|
809
|
+
} else if (location == 'LT') {
|
|
810
|
+
$('div.amap-maptypecontrol').css({ left: config.satelliteSwitch.offset[0] + 64, top: config.satelliteSwitch.offset[1], right: 'inherit', bottom: 'inherit' });
|
|
811
|
+
} else if (location == 'LB') {
|
|
812
|
+
$('div.amap-maptypecontrol').css({ left: config.satelliteSwitch.offset[0] + 64, bottom: config.satelliteSwitch.offset[1] + 84, right: 'inherit', top: 'inherit' });
|
|
813
|
+
} else if (location == 'RB') {
|
|
814
|
+
$('div.amap-maptypecontrol').css({ right: config.satelliteSwitch.offset[0], bottom: config.satelliteSwitch.offset[1] + 84, left: 'inherit', top: 'inherit' });
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
if ($('div.amap-maptypecontrol').length > 0) {
|
|
819
|
+
reloaction();
|
|
820
|
+
} else {
|
|
821
|
+
var timer = setInterval(function () {
|
|
822
|
+
console.log(123);
|
|
823
|
+
if ($('div.amap-maptypecontrol').length > 0) {
|
|
824
|
+
clearInterval(timer);
|
|
825
|
+
reloaction();
|
|
826
|
+
}
|
|
827
|
+
}, 500);
|
|
828
|
+
}
|
|
785
829
|
}
|
|
786
830
|
//获取图元数据
|
|
787
831
|
|
|
@@ -2958,6 +3002,15 @@ var VortexAMap = function (_React$Component) {
|
|
|
2958
3002
|
if (typeof isClearAreaRestriction == 'boolean' && isClearAreaRestriction || isClearAreaRestriction && isClearAreaRestriction !== t.props.isClearAreaRestriction) {
|
|
2959
3003
|
t.clearAreaRestriction();
|
|
2960
3004
|
}
|
|
3005
|
+
|
|
3006
|
+
// 比例尺控件位置改变
|
|
3007
|
+
if (nextProps.showControl && JSON.stringify(nextProps.showControl) != JSON.stringify(t.props.showControl)) {
|
|
3008
|
+
t.showControl(nextProps);
|
|
3009
|
+
}
|
|
3010
|
+
// 地图类型控件位置改变
|
|
3011
|
+
if (nextProps.satelliteSwitch && JSON.stringify(nextProps.satelliteSwitch) != JSON.stringify(t.props.satelliteSwitch)) {
|
|
3012
|
+
t.showMapTypeControl(nextProps);
|
|
3013
|
+
}
|
|
2961
3014
|
}
|
|
2962
3015
|
}, {
|
|
2963
3016
|
key: 'componentWillUnmount',
|
package/lib/VtxMap/BMap/Map.js
CHANGED
|
@@ -37,13 +37,6 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
|
|
37
37
|
var Set = _immutable2.default.Set;
|
|
38
38
|
//公共地址配置
|
|
39
39
|
|
|
40
|
-
// 百度地图js文件内做了一些额外的http or https判断
|
|
41
|
-
// 如果协议为Https,我们需要改动全局变量BMAP_PROTOCOL和BMap_loadScriptTime
|
|
42
|
-
if (window.location.protocol === 'https:') {
|
|
43
|
-
window.BMAP_PROTOCOL = "https";
|
|
44
|
-
window.BMap_loadScriptTime = new Date().getTime();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
40
|
var gisMapConstant = {
|
|
48
41
|
circle: 'BMAP_POINT_SHAPE_CIRCLE', //圆形
|
|
49
42
|
star: 1, //星形
|
|
@@ -2222,48 +2215,63 @@ var BaiduMap = function (_React$Component) {
|
|
|
2222
2215
|
|
|
2223
2216
|
}, {
|
|
2224
2217
|
key: 'showControl',
|
|
2225
|
-
value: function showControl() {
|
|
2218
|
+
value: function showControl(props) {
|
|
2226
2219
|
var t = this,
|
|
2227
2220
|
location = t.AnchorConstant['tr'],
|
|
2228
2221
|
type = '',
|
|
2229
2222
|
offset = null,
|
|
2230
2223
|
scaleOffset = null;
|
|
2231
|
-
|
|
2232
|
-
|
|
2224
|
+
var config = props || t.props;
|
|
2225
|
+
if (t.scaleControl) {
|
|
2226
|
+
t.state.gis.removeControl(t.scaleControl);
|
|
2227
|
+
}
|
|
2228
|
+
if (t.navigationControl) {
|
|
2229
|
+
t.state.gis.removeControl(t.navigationControl);
|
|
2230
|
+
}
|
|
2231
|
+
if (config.showControl.location) {
|
|
2232
|
+
location = t.AnchorConstant[config.showControl.location];
|
|
2233
2233
|
}
|
|
2234
|
-
if (
|
|
2235
|
-
type = t.NavigationConstant[
|
|
2234
|
+
if (config.showControl.type) {
|
|
2235
|
+
type = t.NavigationConstant[config.showControl.type];
|
|
2236
2236
|
}
|
|
2237
|
-
if (
|
|
2238
|
-
offset = new BMap.Size(
|
|
2239
|
-
scaleOffset = new BMap.Size(
|
|
2237
|
+
if (config.showControl.offset && config.showControl.offset.length > 0) {
|
|
2238
|
+
offset = new BMap.Size(config.showControl.offset[0], config.showControl.offset[1]);
|
|
2239
|
+
scaleOffset = new BMap.Size(config.showControl.offset[0] + 70, config.showControl.offset[1]);
|
|
2240
2240
|
}
|
|
2241
2241
|
// 左上角,添加比例尺
|
|
2242
2242
|
var control = new BMap.ScaleControl({ anchor: location, offset: scaleOffset });
|
|
2243
2243
|
t.state.gis.addControl(control);
|
|
2244
|
+
t.scaleControl = control;
|
|
2244
2245
|
if (type !== 'null') {
|
|
2245
2246
|
//右上角,仅包含平移和缩放按钮
|
|
2246
2247
|
var navigation = new BMap.NavigationControl({ anchor: location, type: type, offset: offset });
|
|
2247
2248
|
t.state.gis.addControl(navigation);
|
|
2249
|
+
t.navigationControl = navigation;
|
|
2248
2250
|
}
|
|
2249
2251
|
}
|
|
2250
2252
|
//展示地图切换控件
|
|
2251
2253
|
|
|
2252
2254
|
}, {
|
|
2253
2255
|
key: 'showMapTypeControl',
|
|
2254
|
-
value: function showMapTypeControl() {
|
|
2256
|
+
value: function showMapTypeControl(props) {
|
|
2255
2257
|
var t = this,
|
|
2256
2258
|
location = t.AnchorConstant['br'],
|
|
2257
2259
|
offset = null;
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
+
var config = props || t.props;
|
|
2261
|
+
if (t.mapTypeControl) {
|
|
2262
|
+
t.state.gis.removeControl(t.mapTypeControl);
|
|
2260
2263
|
}
|
|
2261
|
-
if (
|
|
2262
|
-
|
|
2264
|
+
if (config.satelliteSwitch.location) {
|
|
2265
|
+
location = t.AnchorConstant[config.satelliteSwitch.location];
|
|
2263
2266
|
}
|
|
2267
|
+
if (config.satelliteSwitch.offset && config.satelliteSwitch.offset.length > 0) {
|
|
2268
|
+
offset = new BMap.Size(config.satelliteSwitch.offset[0], config.satelliteSwitch.offset[1]);
|
|
2269
|
+
}
|
|
2270
|
+
var mapTypes = [BMAP_NORMAL_MAP, BMAP_SATELLITE_MAP, BMAP_HYBRID_MAP];
|
|
2264
2271
|
// 地图切换控件
|
|
2265
|
-
var control = new BMap.MapTypeControl({ anchor: location, type:
|
|
2272
|
+
var control = new BMap.MapTypeControl({ mapTypes: mapTypes, anchor: location, type: BMAP_MAPTYPE_CONTROL_HORIZONTAL, offset: offset });
|
|
2266
2273
|
t.state.gis.addControl(control);
|
|
2274
|
+
t.mapTypeControl = control;
|
|
2267
2275
|
}
|
|
2268
2276
|
/*设置显示区域*/
|
|
2269
2277
|
|
|
@@ -3119,6 +3127,14 @@ var BaiduMap = function (_React$Component) {
|
|
|
3119
3127
|
t.removeGraphic(item.id, item.type);
|
|
3120
3128
|
});
|
|
3121
3129
|
}
|
|
3130
|
+
// 比例尺控件位置改变
|
|
3131
|
+
if (nextProps.showControl && JSON.stringify(nextProps.showControl) != JSON.stringify(t.props.showControl)) {
|
|
3132
|
+
t.showControl(nextProps);
|
|
3133
|
+
}
|
|
3134
|
+
// 地图类型控件位置改变
|
|
3135
|
+
if (nextProps.satelliteSwitch && JSON.stringify(nextProps.satelliteSwitch) != JSON.stringify(t.props.satelliteSwitch)) {
|
|
3136
|
+
t.showMapTypeControl(nextProps);
|
|
3137
|
+
}
|
|
3122
3138
|
}
|
|
3123
3139
|
}, {
|
|
3124
3140
|
key: 'componentWillUnmount',
|
package/lib/VtxMap/TMap/TMap.js
CHANGED
|
@@ -565,41 +565,75 @@ var TMap = function (_React$Component) {
|
|
|
565
565
|
|
|
566
566
|
}, {
|
|
567
567
|
key: 'showControl',
|
|
568
|
-
value: function showControl() {
|
|
568
|
+
value: function showControl(props) {
|
|
569
569
|
var t = this,
|
|
570
570
|
location = t.AnchorConstant['tr'],
|
|
571
571
|
offset = null,
|
|
572
572
|
scaleOffset = null;
|
|
573
|
-
|
|
574
|
-
|
|
573
|
+
var config = props || t.props;
|
|
574
|
+
if (t.scaleControl) {
|
|
575
|
+
t.state.gis.removeControl(t.scaleControl);
|
|
576
|
+
}
|
|
577
|
+
if (t.navigationControl) {
|
|
578
|
+
t.state.gis.removeControl(t.navigationControl);
|
|
579
|
+
}
|
|
580
|
+
if (config.showControl.location) {
|
|
581
|
+
location = t.AnchorConstant[config.showControl.location];
|
|
575
582
|
}
|
|
576
|
-
if (t.props.showControl.offset && t.props.showControl.offset.length > 0) {}
|
|
577
|
-
// TODO不支持偏移
|
|
578
|
-
|
|
579
583
|
// 添加比例尺
|
|
580
584
|
var control = new T.Control.Scale({ position: location, offset: scaleOffset });
|
|
581
585
|
t.state.gis.addControl(control);
|
|
586
|
+
t.scaleControl = control;
|
|
582
587
|
// 缩放地图
|
|
583
588
|
var navigation = new T.Control.Zoom({ position: location, offset: offset });
|
|
584
589
|
t.state.gis.addControl(navigation);
|
|
590
|
+
t.navigationControl = navigation;
|
|
591
|
+
|
|
592
|
+
// TODO不支持偏移,手动偏移
|
|
593
|
+
if (config.showControl.offset && config.showControl.offset.length > 0) {
|
|
594
|
+
if (location == "topright") {
|
|
595
|
+
$('div.tdt-top.tdt-right').css({ right: config.showControl.offset[0], top: config.showControl.offset[1] });
|
|
596
|
+
} else if (location == "topleft") {
|
|
597
|
+
$('div.tdt-top.tdt-left').css({ left: config.showControl.offset[0], top: config.showControl.offset[1] });
|
|
598
|
+
} else if (location == "bottomleft") {
|
|
599
|
+
$('div.tdt-bottom.tdt-left').css({ left: config.showControl.offset[0], bottom: config.showControl.offset[1] });
|
|
600
|
+
} else if (location == "bottomright") {
|
|
601
|
+
$('div.tdt-bottom.tdt-right').css({ right: config.showControl.offset[0], bottom: config.showControl.offset[1] });
|
|
602
|
+
}
|
|
603
|
+
}
|
|
585
604
|
}
|
|
586
605
|
//展示地图切换控件
|
|
587
606
|
|
|
588
607
|
}, {
|
|
589
608
|
key: 'showMapTypeControl',
|
|
590
|
-
value: function showMapTypeControl() {
|
|
609
|
+
value: function showMapTypeControl(props) {
|
|
591
610
|
var t = this,
|
|
592
611
|
location = t.AnchorConstant['br'],
|
|
593
612
|
offset = null;
|
|
594
|
-
|
|
595
|
-
|
|
613
|
+
var config = props || t.props;
|
|
614
|
+
if (t.mapTypeControl) {
|
|
615
|
+
t.state.gis.removeControl(t.mapTypeControl);
|
|
616
|
+
}
|
|
617
|
+
if (config.satelliteSwitch.location) {
|
|
618
|
+
location = t.AnchorConstant[config.satelliteSwitch.location];
|
|
596
619
|
}
|
|
597
|
-
if (t.props.satelliteSwitch.offset && t.props.satelliteSwitch.offset.length > 0) {}
|
|
598
|
-
// TODO不支持偏移
|
|
599
|
-
|
|
600
620
|
// 地图切换控件
|
|
601
621
|
var control = new T.Control.MapType({ position: location, offset: offset });
|
|
602
622
|
t.state.gis.addControl(control);
|
|
623
|
+
t.mapTypeControl = control;
|
|
624
|
+
|
|
625
|
+
// TODO不支持偏移,手动偏移
|
|
626
|
+
if (config.satelliteSwitch.offset && config.satelliteSwitch.offset.length > 0) {
|
|
627
|
+
if (location == "topright") {
|
|
628
|
+
$('div.tdt-top.tdt-right').css({ right: config.satelliteSwitch.offset[0], top: config.satelliteSwitch.offset[1] });
|
|
629
|
+
} else if (location == "topleft") {
|
|
630
|
+
$('div.tdt-top.tdt-left').css({ left: config.satelliteSwitch.offset[0], top: config.satelliteSwitch.offset[1] });
|
|
631
|
+
} else if (location == "bottomleft") {
|
|
632
|
+
$('div.tdt-bottom.tdt-left').css({ left: config.satelliteSwitch.offset[0], bottom: config.satelliteSwitch.offset[1] });
|
|
633
|
+
} else if (location == "bottomright") {
|
|
634
|
+
$('div.tdt-bottom.tdt-right').css({ right: config.satelliteSwitch.offset[0], bottom: config.satelliteSwitch.offset[1] });
|
|
635
|
+
}
|
|
636
|
+
}
|
|
603
637
|
}
|
|
604
638
|
//测距
|
|
605
639
|
|
|
@@ -3106,6 +3140,15 @@ var TMap = function (_React$Component) {
|
|
|
3106
3140
|
}
|
|
3107
3141
|
}, 100);
|
|
3108
3142
|
}
|
|
3143
|
+
|
|
3144
|
+
// 比例尺控件位置改变
|
|
3145
|
+
if (nextProps.showControl && JSON.stringify(nextProps.showControl) != JSON.stringify(t.props.showControl)) {
|
|
3146
|
+
t.showControl(nextProps);
|
|
3147
|
+
}
|
|
3148
|
+
// 地图类型控件位置改变
|
|
3149
|
+
if (nextProps.satelliteSwitch && JSON.stringify(nextProps.satelliteSwitch) != JSON.stringify(t.props.satelliteSwitch)) {
|
|
3150
|
+
t.showMapTypeControl(nextProps);
|
|
3151
|
+
}
|
|
3109
3152
|
}
|
|
3110
3153
|
}, {
|
|
3111
3154
|
key: 'componentWillUnmount',
|