Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

这个插件中view 视图和 插件Vue Baidu Map共同使用的时候,map会无法定位,导致报错 #156

Open
anpmd opened this issue Oct 14, 2023 · 0 comments

Comments

@anpmd
Copy link

anpmd commented Oct 14, 2023

<script> import { BmlLushu, MapvLayer } from "vue-baidu-map"; import * as mapv from 'mapv' import * as mapvgl from "mapvgl"; export default { data() { return { center: { lng: 0, lat: 0 }, zoom: 3, markerPoint: { lng: 116.404, lat: 39.915 }, points: [], play: true, path: [], icon: { url: "http://api.map.baidu.com/library/LuShu/1.2/examples/car.png", size: { width: 52, height: 26 }, opts: { anchor: { width: 27, height: 13 } }, }, speed: 5000, qianxiData: [], map: "", //地图 BMap:'' }; }, components: { BmlLushu, MapvLayer, }, methods: { handler({ BMap, map }) { console.log(BMap, map); this.map = map; this.BMap =BMap this.center.lng = 116.404; this.center.lat = 39.915; this.zoom = 16; this.createMapv(BMap, map); }, createMapv(BMap, map) { // 起始城市 终止城市 const fromCenter = mapv.utilCityCenter.getCenterByCityName("北京"); const toCenter = mapv.utilCityCenter.getCenterByCityName("广东"); console.log(fromCenter, toCenter); // 生成贝塞尔曲线数据 const curve = new mapvgl.BezierCurve({ start: [fromCenter.lng, fromCenter.lat], end: [toCenter.lng, toCenter.lat], }); const curveModelData = curve.getPoints(); console.log(curveModelData, "curveModelData"); // 生产数据 let data = []; data.push({ geometry: { type: "LineString", coordinates: curveModelData, }, properties: { count: Math.random(), }, }); // 创建视图 var view = new mapvgl.View({ map: map, effects: [ new mapvgl.BrightEffect({ threshold: 0, blurSize: 2, clarity: 1, }), ], }); // 飞线 let lineLayer = new mapvgl.LineLayer({ blend: "lighter", width: 2, color: "rgba(33, 242, 214, 0.6)", }); // view.addLayer(lineLayer); lineLayer.setData(data); console.log(lineLayer,'lineLayer'); } }, }; </script>

这个时候页面会报错 Cannot read properties of undefined (reading 'ratio')

请问,这两个插件能同时使用吗? 如果可以,这里的view 始化MapVGL容器对象,怎么使用?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant