@vtx/map 1.0.3 → 1.0.7
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 +102 -8
- package/lib/VtxMap/BMap/Map.js +72 -34
- package/lib/VtxMap/TMap/TMap.js +86 -56
- package/package.json +1 -1
package/lib/VtxMap/AMap/AMap.js
CHANGED
|
@@ -91,6 +91,12 @@ var VortexAMap = function (_React$Component) {
|
|
|
91
91
|
rectangle: []
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
+
_this.AnchorConstant = {
|
|
95
|
+
tr: 'RT',
|
|
96
|
+
tl: 'LT',
|
|
97
|
+
bl: 'LB',
|
|
98
|
+
br: 'RB'
|
|
99
|
+
};
|
|
94
100
|
_this.loadMapJs();
|
|
95
101
|
return _this;
|
|
96
102
|
}
|
|
@@ -103,7 +109,7 @@ var VortexAMap = function (_React$Component) {
|
|
|
103
109
|
resolve(window.AMap);
|
|
104
110
|
} else {
|
|
105
111
|
$.getScript(_default2.default.mapServerURL + '/A_content.js', function () {
|
|
106
|
-
$.getScript('//webapi.amap.com/maps?v=1.4.14&key=e59ef9272e3788ac59d9a22f0f8cf9fe&plugin=AMap.Geolocation,AMap.MarkerClusterer,AMap.Scale,AMap.ToolBar,AMap.DistrictSearch,AMap.RangingTool,AMap.MouseTool,AMap.PolyEditor,AMap.CircleEditor,AMap.PlaceSearch,AMap.Heatmap', function () {
|
|
112
|
+
$.getScript('//webapi.amap.com/maps?v=1.4.14&key=e59ef9272e3788ac59d9a22f0f8cf9fe&plugin=AMap.Geolocation,AMap.MarkerClusterer,AMap.MapType,AMap.Scale,AMap.ToolBar,AMap.DistrictSearch,AMap.RangingTool,AMap.MouseTool,AMap.PolyEditor,AMap.CircleEditor,AMap.PlaceSearch,AMap.Heatmap', function () {
|
|
107
113
|
var PointCollection = new Promise(function (resolve, reject) {
|
|
108
114
|
$.getScript(_default2.default.mapServerURL + '/GPointCollection.js', function () {
|
|
109
115
|
resolve();
|
|
@@ -111,7 +117,7 @@ var VortexAMap = function (_React$Component) {
|
|
|
111
117
|
});
|
|
112
118
|
Promise.all([PointCollection]).then(function () {
|
|
113
119
|
(function setTime() {
|
|
114
|
-
var allEvents = [window.AMap, 'MarkerClusterer', 'Scale', 'ToolBar', 'DistrictSearch', 'RangingTool', 'MouseTool', 'PolyEditor', 'CircleEditor', 'PlaceSearch', 'Heatmap'];
|
|
120
|
+
var allEvents = [window.AMap, 'MarkerClusterer', 'MapType', 'Scale', 'ToolBar', 'DistrictSearch', 'RangingTool', 'MouseTool', 'PolyEditor', 'CircleEditor', 'PlaceSearch', 'Heatmap'];
|
|
115
121
|
var isLoading = true;
|
|
116
122
|
for (var i = 0; i <= allEvents.length - 1; i++) {
|
|
117
123
|
if (i === 0) {
|
|
@@ -208,7 +214,10 @@ var VortexAMap = function (_React$Component) {
|
|
|
208
214
|
if (showControl) {
|
|
209
215
|
t.showControl();
|
|
210
216
|
}
|
|
211
|
-
|
|
217
|
+
//添加地图类型控件
|
|
218
|
+
if (t.props.satelliteSwitch) {
|
|
219
|
+
t.showMapTypeControl();
|
|
220
|
+
}
|
|
212
221
|
//画边界线
|
|
213
222
|
if (boundaryName instanceof Array && boundaryName.length > 0) {
|
|
214
223
|
t.addBaiduBoundary(boundaryName);
|
|
@@ -735,11 +744,87 @@ var VortexAMap = function (_React$Component) {
|
|
|
735
744
|
|
|
736
745
|
}, {
|
|
737
746
|
key: 'showControl',
|
|
738
|
-
value: function showControl() {
|
|
739
|
-
var t = this
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
747
|
+
value: function showControl(props) {
|
|
748
|
+
var t = this,
|
|
749
|
+
location = 'RT',
|
|
750
|
+
offset = null;
|
|
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);
|
|
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]);
|
|
764
|
+
}
|
|
765
|
+
// 添加比例尺
|
|
766
|
+
var control = new AMap.Scale({ position: location, offset: scaleOffset });
|
|
767
|
+
t.state.gis.addControl(control);
|
|
768
|
+
t.scaleControl = control;
|
|
769
|
+
// 包含平移和缩放按钮
|
|
770
|
+
var navigation = new AMap.ToolBar({ position: location, offset: offset });
|
|
771
|
+
t.state.gis.addControl(navigation);
|
|
772
|
+
t.navigationControl = navigation;
|
|
773
|
+
}
|
|
774
|
+
//展示地图切换控件
|
|
775
|
+
|
|
776
|
+
}, {
|
|
777
|
+
key: 'showMapTypeControl',
|
|
778
|
+
value: function showMapTypeControl(props) {
|
|
779
|
+
var t = this,
|
|
780
|
+
location = 'RT',
|
|
781
|
+
offset = null;
|
|
782
|
+
var config = props || t.props;
|
|
783
|
+
if (t.mapTypeControl) {
|
|
784
|
+
t.state.gis.removeControl(t.mapTypeControl);
|
|
785
|
+
}
|
|
786
|
+
if (config.satelliteSwitch.location) {
|
|
787
|
+
location = t.AnchorConstant[config.satelliteSwitch.location];
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// 地图切换控件
|
|
791
|
+
var control = new AMap.MapType({ position: location, offset: offset });
|
|
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);
|
|
743
828
|
}
|
|
744
829
|
}
|
|
745
830
|
//获取图元数据
|
|
@@ -2917,6 +3002,15 @@ var VortexAMap = function (_React$Component) {
|
|
|
2917
3002
|
if (typeof isClearAreaRestriction == 'boolean' && isClearAreaRestriction || isClearAreaRestriction && isClearAreaRestriction !== t.props.isClearAreaRestriction) {
|
|
2918
3003
|
t.clearAreaRestriction();
|
|
2919
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
|
+
}
|
|
2920
3014
|
}
|
|
2921
3015
|
}, {
|
|
2922
3016
|
key: 'componentWillUnmount',
|
package/lib/VtxMap/BMap/Map.js
CHANGED
|
@@ -322,6 +322,19 @@ var BaiduMap = function (_React$Component) {
|
|
|
322
322
|
} else {
|
|
323
323
|
window.VtxMap = {};
|
|
324
324
|
}
|
|
325
|
+
// 控件位置常量
|
|
326
|
+
t.AnchorConstant = {
|
|
327
|
+
tr: BMAP_ANCHOR_TOP_RIGHT,
|
|
328
|
+
tl: BMAP_ANCHOR_TOP_LEFT,
|
|
329
|
+
bl: BMAP_ANCHOR_BOTTOM_LEFT,
|
|
330
|
+
br: BMAP_ANCHOR_BOTTOM_RIGHT
|
|
331
|
+
// 平移缩放控件大小
|
|
332
|
+
};t.NavigationConstant = {
|
|
333
|
+
large: BMAP_NAVIGATION_CONTROL_LARGE,
|
|
334
|
+
small: BMAP_NAVIGATION_CONTROL_SMALL,
|
|
335
|
+
pan: BMAP_NAVIGATION_CONTROL_PAN,
|
|
336
|
+
zoom: BMAP_NAVIGATION_CONTROL_ZOOM
|
|
337
|
+
};
|
|
325
338
|
var map = window.VtxMap[mapId] = t.state.gis = new BMap.Map(mapId.toString(), {
|
|
326
339
|
enableMapClick: false,
|
|
327
340
|
minZoom: options.minZoom,
|
|
@@ -340,9 +353,9 @@ var BaiduMap = function (_React$Component) {
|
|
|
340
353
|
}, 500);
|
|
341
354
|
// 初始化地图,设置中心点坐标和地图级别
|
|
342
355
|
map.centerAndZoom(new BMap.Point(parseFloat(options.center[0]), parseFloat(options.center[1])), options.zoom);
|
|
343
|
-
//添加地图类型控件
|
|
356
|
+
//添加地图类型控件
|
|
344
357
|
if (t.props.satelliteSwitch) {
|
|
345
|
-
|
|
358
|
+
t.showMapTypeControl();
|
|
346
359
|
}
|
|
347
360
|
//初始化路况控件
|
|
348
361
|
if (!t._trafficCtrl) {
|
|
@@ -2209,47 +2222,64 @@ var BaiduMap = function (_React$Component) {
|
|
|
2209
2222
|
|
|
2210
2223
|
}, {
|
|
2211
2224
|
key: 'showControl',
|
|
2212
|
-
value: function showControl() {
|
|
2225
|
+
value: function showControl(props) {
|
|
2213
2226
|
var t = this,
|
|
2214
|
-
location =
|
|
2215
|
-
type = ''
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
location = BMAP_ANCHOR_BOTTOM_LEFT;
|
|
2222
|
-
break;
|
|
2223
|
-
case 'tr':
|
|
2224
|
-
location = BMAP_ANCHOR_TOP_RIGHT;
|
|
2225
|
-
break;
|
|
2226
|
-
case 'br':
|
|
2227
|
-
location = BMAP_ANCHOR_BOTTOM_RIGHT;
|
|
2228
|
-
break;
|
|
2227
|
+
location = t.AnchorConstant['tr'],
|
|
2228
|
+
type = '',
|
|
2229
|
+
offset = null,
|
|
2230
|
+
scaleOffset = null;
|
|
2231
|
+
var config = props || t.props;
|
|
2232
|
+
if (t.scaleControl) {
|
|
2233
|
+
t.state.gis.removeControl(t.scaleControl);
|
|
2229
2234
|
}
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
break;
|
|
2235
|
+
if (t.navigationControl) {
|
|
2236
|
+
t.state.gis.removeControl(t.navigationControl);
|
|
2237
|
+
}
|
|
2238
|
+
if (config.showControl.location) {
|
|
2239
|
+
location = t.AnchorConstant[config.showControl.location];
|
|
2240
|
+
}
|
|
2241
|
+
if (config.showControl.type) {
|
|
2242
|
+
type = t.NavigationConstant[config.showControl.type];
|
|
2243
|
+
}
|
|
2244
|
+
if (config.showControl.offset && config.showControl.offset.length > 0) {
|
|
2245
|
+
offset = new BMap.Size(config.showControl.offset[0], config.showControl.offset[1]);
|
|
2246
|
+
scaleOffset = new BMap.Size(config.showControl.offset[0] + 70, config.showControl.offset[1]);
|
|
2243
2247
|
}
|
|
2244
2248
|
// 左上角,添加比例尺
|
|
2245
|
-
var control = new BMap.ScaleControl({ anchor: location });
|
|
2249
|
+
var control = new BMap.ScaleControl({ anchor: location, offset: scaleOffset });
|
|
2246
2250
|
t.state.gis.addControl(control);
|
|
2251
|
+
t.scaleControl = control;
|
|
2247
2252
|
if (type !== 'null') {
|
|
2248
2253
|
//右上角,仅包含平移和缩放按钮
|
|
2249
|
-
var navigation = new BMap.NavigationControl({ anchor: location, type: type });
|
|
2254
|
+
var navigation = new BMap.NavigationControl({ anchor: location, type: type, offset: offset });
|
|
2250
2255
|
t.state.gis.addControl(navigation);
|
|
2256
|
+
t.navigationControl = navigation;
|
|
2251
2257
|
}
|
|
2252
2258
|
}
|
|
2259
|
+
//展示地图切换控件
|
|
2260
|
+
|
|
2261
|
+
}, {
|
|
2262
|
+
key: 'showMapTypeControl',
|
|
2263
|
+
value: function showMapTypeControl(props) {
|
|
2264
|
+
var t = this,
|
|
2265
|
+
location = t.AnchorConstant['br'],
|
|
2266
|
+
offset = null;
|
|
2267
|
+
var config = props || t.props;
|
|
2268
|
+
if (t.mapTypeControl) {
|
|
2269
|
+
t.state.gis.removeControl(t.mapTypeControl);
|
|
2270
|
+
}
|
|
2271
|
+
if (config.satelliteSwitch.location) {
|
|
2272
|
+
location = t.AnchorConstant[config.satelliteSwitch.location];
|
|
2273
|
+
}
|
|
2274
|
+
if (config.satelliteSwitch.offset && config.satelliteSwitch.offset.length > 0) {
|
|
2275
|
+
offset = new BMap.Size(config.satelliteSwitch.offset[0], config.satelliteSwitch.offset[1]);
|
|
2276
|
+
}
|
|
2277
|
+
var mapTypes = [BMAP_NORMAL_MAP, BMAP_SATELLITE_MAP, BMAP_HYBRID_MAP];
|
|
2278
|
+
// 地图切换控件
|
|
2279
|
+
var control = new BMap.MapTypeControl({ mapTypes: mapTypes, anchor: location, type: BMAP_MAPTYPE_CONTROL_HORIZONTAL, offset: offset });
|
|
2280
|
+
t.state.gis.addControl(control);
|
|
2281
|
+
t.mapTypeControl = control;
|
|
2282
|
+
}
|
|
2253
2283
|
/*设置显示区域*/
|
|
2254
2284
|
|
|
2255
2285
|
}, {
|
|
@@ -3104,6 +3134,14 @@ var BaiduMap = function (_React$Component) {
|
|
|
3104
3134
|
t.removeGraphic(item.id, item.type);
|
|
3105
3135
|
});
|
|
3106
3136
|
}
|
|
3137
|
+
// 比例尺控件位置改变
|
|
3138
|
+
if (nextProps.showControl && JSON.stringify(nextProps.showControl) != JSON.stringify(t.props.showControl)) {
|
|
3139
|
+
t.showControl(nextProps);
|
|
3140
|
+
}
|
|
3141
|
+
// 地图类型控件位置改变
|
|
3142
|
+
if (nextProps.satelliteSwitch && JSON.stringify(nextProps.satelliteSwitch) != JSON.stringify(t.props.satelliteSwitch)) {
|
|
3143
|
+
t.showMapTypeControl(nextProps);
|
|
3144
|
+
}
|
|
3107
3145
|
}
|
|
3108
3146
|
}, {
|
|
3109
3147
|
key: 'componentWillUnmount',
|
|
@@ -3117,7 +3155,7 @@ var BaiduMap = function (_React$Component) {
|
|
|
3117
3155
|
if (t.moveToTimer) {
|
|
3118
3156
|
clearInterval(t.moveToTimer);
|
|
3119
3157
|
}
|
|
3120
|
-
window.VtxMap[t.state.mapId] = null;
|
|
3158
|
+
window.VtxMap && (window.VtxMap[t.state.mapId] = null);
|
|
3121
3159
|
}
|
|
3122
3160
|
}]);
|
|
3123
3161
|
|
package/lib/VtxMap/TMap/TMap.js
CHANGED
|
@@ -218,7 +218,10 @@ var TMap = function (_React$Component) {
|
|
|
218
218
|
if (showControl) {
|
|
219
219
|
t.showControl();
|
|
220
220
|
}
|
|
221
|
-
|
|
221
|
+
//添加地图类型控件
|
|
222
|
+
if (t.props.satelliteSwitch) {
|
|
223
|
+
t.showMapTypeControl();
|
|
224
|
+
}
|
|
222
225
|
// //画边界线
|
|
223
226
|
// if(boundaryName instanceof Array && boundaryName.length>0){
|
|
224
227
|
// t.addBaiduBoundary(boundaryName);
|
|
@@ -263,6 +266,13 @@ var TMap = function (_React$Component) {
|
|
|
263
266
|
if (!window.VtxMap) {
|
|
264
267
|
window.VtxMap = {};
|
|
265
268
|
}
|
|
269
|
+
// 控件位置常量
|
|
270
|
+
t.AnchorConstant = {
|
|
271
|
+
tr: T_ANCHOR_TOP_RIGHT,
|
|
272
|
+
tl: T_ANCHOR_TOP_LEFT,
|
|
273
|
+
bl: T_ANCHOR_BOTTOM_LEFT,
|
|
274
|
+
br: T_ANCHOR_BOTTOM_RIGHT
|
|
275
|
+
};
|
|
266
276
|
window.VtxMap[mapId] = t.state.gis = new T.Map(mapId.toString(), {
|
|
267
277
|
//zoom等级,和百度一样默认10
|
|
268
278
|
zoom: mapZoomLevel || 10,
|
|
@@ -555,63 +565,74 @@ var TMap = function (_React$Component) {
|
|
|
555
565
|
|
|
556
566
|
}, {
|
|
557
567
|
key: 'showControl',
|
|
558
|
-
value: function showControl() {
|
|
559
|
-
var t = this
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
568
|
+
value: function showControl(props) {
|
|
569
|
+
var t = this,
|
|
570
|
+
location = t.AnchorConstant['tr'],
|
|
571
|
+
offset = null,
|
|
572
|
+
scaleOffset = null;
|
|
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];
|
|
582
|
+
}
|
|
583
|
+
// 添加比例尺
|
|
584
|
+
var control = new T.Control.Scale({ position: location, offset: scaleOffset });
|
|
585
|
+
t.state.gis.addControl(control);
|
|
586
|
+
t.scaleControl = control;
|
|
587
|
+
// 缩放地图
|
|
588
|
+
var navigation = new T.Control.Zoom({ position: location, offset: offset });
|
|
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
|
+
}
|
|
604
|
+
}
|
|
605
|
+
//展示地图切换控件
|
|
606
|
+
|
|
607
|
+
}, {
|
|
608
|
+
key: 'showMapTypeControl',
|
|
609
|
+
value: function showMapTypeControl(props) {
|
|
610
|
+
var t = this,
|
|
611
|
+
location = t.AnchorConstant['br'],
|
|
612
|
+
offset = null;
|
|
613
|
+
var config = props || t.props;
|
|
614
|
+
if (t.mapTypeControl) {
|
|
615
|
+
t.state.gis.removeControl(t.mapTypeControl);
|
|
601
616
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
if (t.props.showControl && t.props.showControl.location == 'bl') {
|
|
605
|
-
var dom = fdom.getElementsByClassName('tdt-control-scale')[0];
|
|
606
|
-
dom.style.position = 'relative';
|
|
607
|
-
dom.style.top = '65px';
|
|
608
|
-
dom.style.left = '45px';
|
|
617
|
+
if (config.satelliteSwitch.location) {
|
|
618
|
+
location = t.AnchorConstant[config.satelliteSwitch.location];
|
|
609
619
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
620
|
+
// 地图切换控件
|
|
621
|
+
var control = new T.Control.MapType({ position: location, offset: offset });
|
|
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
|
+
}
|
|
615
636
|
}
|
|
616
637
|
}
|
|
617
638
|
//测距
|
|
@@ -3119,6 +3140,15 @@ var TMap = function (_React$Component) {
|
|
|
3119
3140
|
}
|
|
3120
3141
|
}, 100);
|
|
3121
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
|
+
}
|
|
3122
3152
|
}
|
|
3123
3153
|
}, {
|
|
3124
3154
|
key: 'componentWillUnmount',
|