# up driving
This commit is contained in:
parent
97af9a4e6a
commit
b21d0af572
|
@ -11,6 +11,6 @@
|
||||||
<!-- <script src=<%= htmlWebpackPlugin.options.path %>/tinymce4.7.5/tinymce.min.js></script> -->
|
<!-- <script src=<%= htmlWebpackPlugin.options.path %>/tinymce4.7.5/tinymce.min.js></script> -->
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<!-- built files will be auto injected -->
|
<!-- built files will be auto injected -->
|
||||||
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.8&key=49842c6fe4d24df80871faec2e272a00&plugin=AMap.Transfer"></script>
|
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.8&key=49842c6fe4d24df80871faec2e272a00&plugin=AMap.Driving"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<div id="map-container" tabindex="0"></div>
|
<div id="map-container" tabindex="0"></div>
|
||||||
<div id="panel"></div>
|
<div v-show="flag" id="panel"></div>
|
||||||
|
<div v-show="mapClick && flag" id='bt-wrapper'>
|
||||||
|
<div id='bt'>点击去高德地图</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -15,6 +18,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
map: null,
|
map: null,
|
||||||
flag: false,
|
flag: false,
|
||||||
|
mapClick: false,
|
||||||
defaultPositions: [
|
defaultPositions: [
|
||||||
{
|
{
|
||||||
title: '海洋公园',
|
title: '海洋公园',
|
||||||
|
@ -161,7 +165,7 @@ export default {
|
||||||
}
|
}
|
||||||
const map = new AMap.Map('map-container', {
|
const map = new AMap.Map('map-container', {
|
||||||
// center: this.coordinate,
|
// center: this.coordinate,
|
||||||
center: [116.397428, 39.90923],
|
center: [113.203460828994, 22.64902452257],
|
||||||
resizeEnable: true,
|
resizeEnable: true,
|
||||||
zoom: 13
|
zoom: 13
|
||||||
})
|
})
|
||||||
|
@ -171,29 +175,39 @@ export default {
|
||||||
// title: this.deviceList[0].title,
|
// title: this.deviceList[0].title,
|
||||||
// map: map
|
// map: map
|
||||||
// })
|
// })
|
||||||
const transOptions = {
|
const drivingOptions = {
|
||||||
map: map,
|
map: map,
|
||||||
city: '北京市',
|
// city: '中山市',
|
||||||
panel: 'panel',
|
panel: 'panel'
|
||||||
// cityd:'乌鲁木齐',
|
// cityd:'乌鲁木齐',
|
||||||
policy: AMap.TransferPolicy.LEAST_TIME
|
// policy: AMap.DrivingPolicy.LEAST_TIME
|
||||||
}
|
}
|
||||||
// 构造公交换乘类
|
const driving = new AMap.Driving(drivingOptions)
|
||||||
const transfer = new AMap.Transfer(transOptions)
|
const button = document.getElementById('bt')
|
||||||
// 根据起、终点坐标查询公交换乘路线
|
driving.search(new AMap.LngLat(113.344095, 22.673091), new AMap.LngLat(113.203460828994, 22.64902452257), (status, result) => {
|
||||||
transfer.search(new AMap.LngLat(116.291035, 39.907899), new AMap.LngLat(116.427281, 39.903719))
|
button.onclick = () => {
|
||||||
|
driving.searchOnAMAP({
|
||||||
|
origin: result.origin,
|
||||||
|
destination: result.destination
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.flag = true
|
||||||
|
// if (AMap.UA.mobile) {
|
||||||
|
// document.getElementById('panel').style.display = 'none'
|
||||||
|
// // document.getElementById('bt-wrapper').style.display = 'normal'
|
||||||
|
// }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.mapClick = this.$store.getters.mapClick
|
this.mapClick = this.$store.getters.mapClick
|
||||||
if (!this.mapClick) {
|
// if (!this.mapClick) {
|
||||||
this.flag = true
|
// this.flag = true
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (this.mapClick) {
|
if (this.mapClick) {
|
||||||
this.flag = true
|
|
||||||
const device_id = this.$store.getters.deviceID
|
const device_id = this.$store.getters.deviceID
|
||||||
this.getDevicesInitMap({ device_id })
|
this.getDevicesInitMap({ device_id })
|
||||||
} else {
|
} else {
|
||||||
|
@ -272,5 +286,28 @@ export default {
|
||||||
right: 10px;
|
right: 10px;
|
||||||
width: 250px;
|
width: 250px;
|
||||||
border: solid 1px silver;
|
border: solid 1px silver;
|
||||||
|
margin-top: 100px;
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 768px) {
|
||||||
|
#panel {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#bt-wrapper {
|
||||||
|
position: absolute;
|
||||||
|
width: 2rem;
|
||||||
|
bottom: 15%;
|
||||||
|
right: 10rem;
|
||||||
|
}
|
||||||
|
#bt {
|
||||||
|
font-size: .8rem;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 5px;
|
||||||
|
background-color: #0D9BF2;
|
||||||
|
padding: 6px;
|
||||||
|
width: 160px;
|
||||||
|
color: white;
|
||||||
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue