【类 型】:factor 地图组件token 放到data数据里面调用
【原 因】:方便修改 【过 程】: 【影 响】: # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动
This commit is contained in:
parent
f507e57311
commit
a396b749ee
@ -13,6 +13,7 @@ export default {
|
|||||||
name: 'MapBox',
|
name: 'MapBox',
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
token: 'pk.eyJ1Ijoic3pkb3QiLCJhIjoiY2xhN2pkMWFoMHJ4eTN3cXp6bmlzaHZ0NCJ9.3hH-EAUr0wQCaLvIM2lBMQ',
|
||||||
map: null,
|
map: null,
|
||||||
planes: [], // 飞机对象
|
planes: [], // 飞机对象
|
||||||
lonLats: [], // 航线 所有航点
|
lonLats: [], // 航线 所有航点
|
||||||
@ -217,7 +218,7 @@ export default {
|
|||||||
this.map.on('touchstart', (event) => {
|
this.map.on('touchstart', (event) => {
|
||||||
// 移动端点击事件
|
// 移动端点击事件
|
||||||
pressTimer = setTimeout(() => {
|
pressTimer = setTimeout(() => {
|
||||||
const lonLat = this.map.unproject(event.point)
|
const lonLat = { lon: this.map.unproject(event.point).lng, lat: this.map.unproject(event.point).lat }
|
||||||
// 将经纬度信息传递到组件外部
|
// 将经纬度信息传递到组件外部
|
||||||
this.$emit('longPress', lonLat)
|
this.$emit('longPress', lonLat)
|
||||||
}, 1000) // 作为长按的时间阈值
|
}, 1000) // 作为长按的时间阈值
|
||||||
@ -236,8 +237,7 @@ export default {
|
|||||||
*/
|
*/
|
||||||
async init () {
|
async init () {
|
||||||
// token
|
// token
|
||||||
mapboxgl.accessToken =
|
mapboxgl.accessToken = this.token
|
||||||
'pk.eyJ1Ijoic3pkb3QiLCJhIjoiY2xhN2pkMWFoMHJ4eTN3cXp6bmlzaHZ0NCJ9.3hH-EAUr0wQCaLvIM2lBMQ'
|
|
||||||
// 实例化map
|
// 实例化map
|
||||||
this.map = new mapboxgl.Map({
|
this.map = new mapboxgl.Map({
|
||||||
container: 'map',
|
container: 'map',
|
||||||
|
Loading…
Reference in New Issue
Block a user