tdt-map-vue2 0.1.4 → 0.1.6
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 +3 -1
- package/lib/BaseMap.vue +25 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,8 +37,10 @@ Vue.use(TdtMap, {
|
|
|
37
37
|
| viewDatas | array | 否 | [] | 数据,格式同 datas |
|
|
38
38
|
| viewTimer | number | 否 | 800 | 地图视图改变防抖毫秒数 |
|
|
39
39
|
| viewLocation | boolean | 否 | false | changeView 是否携带城市地址信息 |
|
|
40
|
+
| positionControl | boolean | 否 | true | 是否显示缩放平移控件 |
|
|
41
|
+
| zoomControl | boolean | 否 | true | 是否显示地图缩放控件 |
|
|
40
42
|
| tk | string | 否 | - | 天地图 tk |
|
|
41
|
-
| center | number[] | 否 |
|
|
43
|
+
| center | number[] | 否 | 天安门经纬度 | 地图 center |
|
|
42
44
|
| zoom | number | 否 | 15 | 地图 zoom |
|
|
43
45
|
| mapOptions | object | 否 | - | 百度地图初始化参数 minZoom/maxZoom/mapType |
|
|
44
46
|
| denyRefresh | boolean | 否 | false | 拒绝地图刷新,即地图移动或 zoom 改变不会触发 changeView 事件 |
|
package/lib/BaseMap.vue
CHANGED
|
@@ -22,7 +22,7 @@ export default {
|
|
|
22
22
|
},
|
|
23
23
|
center: {
|
|
24
24
|
type: Array,
|
|
25
|
-
default: () => [
|
|
25
|
+
default: () => ['116.404','39.915'],
|
|
26
26
|
},
|
|
27
27
|
zoom: {
|
|
28
28
|
type: Number,
|
|
@@ -112,7 +112,7 @@ export default {
|
|
|
112
112
|
},
|
|
113
113
|
|
|
114
114
|
mounted() {
|
|
115
|
-
console.log("----------initMap----------");
|
|
115
|
+
// console.log("----------initMap----------");
|
|
116
116
|
// 使用 props.tk,如果为空则使用全局配置的 tk
|
|
117
117
|
installTMap(this.initMap, this.tk);
|
|
118
118
|
},
|
|
@@ -142,7 +142,7 @@ export default {
|
|
|
142
142
|
},
|
|
143
143
|
lines: {
|
|
144
144
|
handler() {
|
|
145
|
-
console.log("----------props.lines------------");
|
|
145
|
+
// console.log("----------props.lines------------");
|
|
146
146
|
|
|
147
147
|
this.removeAllPipelines();
|
|
148
148
|
this.initAllLines(this.lines);
|
|
@@ -181,12 +181,21 @@ export default {
|
|
|
181
181
|
});
|
|
182
182
|
this.map = mapInstance;
|
|
183
183
|
|
|
184
|
+
var globalSw = new TMap.LngLat(-1000, -90); // 全球西南角:西经180,南纬90
|
|
185
|
+
var globalNe = new TMap.LngLat(1000, 90); // 全球东北角:东经180,北纬90
|
|
186
|
+
var globalBounds = new TMap.LngLatBounds(globalSw, globalNe);
|
|
187
|
+
mapInstance.setMaxBounds(globalBounds); // 拖拽超出全球范围会自动弹回
|
|
188
|
+
|
|
189
|
+
// 2. 设置最小缩放等级为3(核心,无法缩放到3级以下)
|
|
190
|
+
mapInstance.setMinZoom(3);
|
|
191
|
+
|
|
184
192
|
const result = this.gcoordTransform(this.center);
|
|
185
193
|
const point = new TMap.LngLat(...result);
|
|
186
194
|
mapInstance.centerAndZoom(point, this.zoom);
|
|
187
195
|
mapInstance.enableScrollWheelZoom();
|
|
188
196
|
mapInstance.enableDoubleClickZoom();
|
|
189
197
|
mapInstance.disableInertia();
|
|
198
|
+
|
|
190
199
|
|
|
191
200
|
// 初始化控制器
|
|
192
201
|
installControls({map:mapInstance, T:TMap,positionControl:this.positionControl,zoomControl:this.zoomControl});
|
|
@@ -262,7 +271,7 @@ export default {
|
|
|
262
271
|
|
|
263
272
|
// 分批次渲染管线
|
|
264
273
|
renderPipelinesInBatches(lines) {
|
|
265
|
-
console.log("----------renderPipelinesInBatches--------",lines);
|
|
274
|
+
// console.log("----------renderPipelinesInBatches--------",lines);
|
|
266
275
|
if (!lines || lines.length === 0) return;
|
|
267
276
|
let pipelines = JSON.parse(JSON.stringify(lines));
|
|
268
277
|
this.removeAllPipelines();
|
|
@@ -286,7 +295,7 @@ export default {
|
|
|
286
295
|
// 异步渲染下一批,避免阻塞主线程
|
|
287
296
|
requestAnimationFrame(renderBatch);
|
|
288
297
|
} else {
|
|
289
|
-
console.log("所有管线渲染完成,总数:", pipelines.length,pipelines);
|
|
298
|
+
// console.log("所有管线渲染完成,总数:", pipelines.length,pipelines);
|
|
290
299
|
this.$emit("renderLine",this.pipelineLayers);
|
|
291
300
|
}
|
|
292
301
|
};
|
|
@@ -299,7 +308,7 @@ export default {
|
|
|
299
308
|
return new this.TMapGL.LngLat(...coord)
|
|
300
309
|
}
|
|
301
310
|
);
|
|
302
|
-
console.log('--------getLine------',pipe,lngLatArr);
|
|
311
|
+
// console.log('--------getLine------',pipe,lngLatArr);
|
|
303
312
|
|
|
304
313
|
const polyline = new this.TMapGL.Polyline(lngLatArr, pipe.lineOptions);
|
|
305
314
|
polyline.addEventListener("mouseover", (e) => {
|
|
@@ -330,7 +339,7 @@ export default {
|
|
|
330
339
|
|
|
331
340
|
// 线段管理
|
|
332
341
|
initAllLines(lines) {
|
|
333
|
-
console.log("----------渲染管线initAllLines--------");
|
|
342
|
+
// console.log("----------渲染管线initAllLines--------");
|
|
334
343
|
|
|
335
344
|
this.renderPipelinesInBatches(lines);
|
|
336
345
|
},
|
|
@@ -387,8 +396,9 @@ export default {
|
|
|
387
396
|
marker = label;}
|
|
388
397
|
} else {
|
|
389
398
|
const icon = new this.TMapGL.Icon({
|
|
390
|
-
iconUrl: data.
|
|
391
|
-
iconSize: new this.TMapGL.Point(
|
|
399
|
+
iconUrl: data.icon || markerIcon,
|
|
400
|
+
iconSize: new this.TMapGL.Point(...(data.iconSize || [30, 30])),
|
|
401
|
+
iconAnchor: new this.TMapGL.Point(...(data.iconAnchor || [0, 0])),
|
|
392
402
|
});
|
|
393
403
|
marker = new this.TMapGL.Marker(point, { icon });
|
|
394
404
|
}
|
|
@@ -399,6 +409,12 @@ export default {
|
|
|
399
409
|
this.$emit("markerClick", { marker, data, e });
|
|
400
410
|
}, 0);
|
|
401
411
|
});
|
|
412
|
+
marker.addEventListener("mouseover", (e) => {
|
|
413
|
+
this.$emit("markerMouseover", { marker, data, e });
|
|
414
|
+
});
|
|
415
|
+
marker.addEventListener('mouseout',e => {
|
|
416
|
+
this.$emit("markerMouseout", { marker, data, e })
|
|
417
|
+
})
|
|
402
418
|
|
|
403
419
|
return { marker };
|
|
404
420
|
},
|