当前位置:网站首页>Use Gaode map JS API 2.0 to load the starting and ending path tracks
Use Gaode map JS API 2.0 to load the starting and ending path tracks
2022-07-23 21:34:00 【coldriversnow】

<template>
<div>
<div class="head">
<breadcrumb></breadcrumb>
</div>
<div class="rightcenter clearfix">
<div class="box">
<div class="right1">
<div id="amap" style="width:98%;height:780px;"></div>
</div>
</div>
</div>
</div>
</template>export default {
name: 'vehicle',
data() {
return {
tableData: [], // The list of data
lineArrLx:[],// Route line drawing point
lineArrLxmd:[],// Pipe network line drawing points
endMarker:null,// End
startMarker:null,// The starting point
lineArrLxGj:[],// Route line drawing point
lineArrLxGjmd:[],// Pipe network line drawing points
endMarkerGj:null,// End
startMarkerGj:null,// The starting point
map: null,
};
},
mounted() {
this.leibiao(this.pageNum, this.pagesize);
},
watch: {},
methods: {
// Get list data
leibiao(pageNum, pagesize) {
// Request data interface
that.tableData = [{
"planRoute": "114.473232,38.007664;114.48542,38.010437;114.512371,38.016252;114.526447,38.023149;114.54533,38.023825",
"trajectory": "114.473232,38.007664;114.48542,38.010437;114.512371,38.016252",
}, {
"planRoute": "114.473232,38.007664;114.48542,38.010437;114.512371,38.016252;114.526447,38.023149;114.54533,38.023825",
"trajectory": "114.473232,38.007664;114.48542,38.010437;114.512371,38.016252",
}];
that.total = Number(res.data.total);
let maplx= res.data.list;
maplx.forEach(function(v,i) {
if(v.planRoute != null){
v.planRoute=v.planRoute.split(";")
v.trajectory=v.trajectory.split(";")
}
});
that.initMap()
that.xianmap(maplx); // Planned driving route
that.xianGjMap(maplx); // Planned driving route
},
/*
* Map making
* */
// Make a map
// standard normal Mirage black dark Moonlight silver light Yuanshandai whitesmoke The grass is green fresh Refined grey grey Doodle graffiti Macaroon macaron Indigo blue blue Polar night blue darkblue Sauce seed wine
// Make a map
// standard normal Mirage black dark Moonlight silver light Yuanshandai whitesmoke The grass is green fresh Refined grey grey Doodle graffiti Macaroon macaron Indigo blue blue Polar night blue darkblue Sauce seed wine
initMap() {
let that=this;
let mapys='amap://styles/macaron';
let mapcenter=[114.473232,38.007664];
// Initialize map
this.map = new AMap.Map('amap', {
resizeEnable: true,
center: mapcenter,
zoom: 13,
viewMode: "2D", // Use 3D View
mapStyle: mapys, // Set the display style of the map
});
this.map.clearMap(); // Remove the map cover
},
// Generate line array
xianmap(gwarry){
let that=this
gwarry.forEach(function(v,i) {
if(v.planRoute != null){
that.mpaxian(v.planRoute,v,'#00aaff')
}
});
},
mpaxian(maplineArr,v,color){
// Coordinate set
let lineArr=[]
maplineArr.forEach(function(q,w) {
lineArr.push(onezhuan(q))
})
function onezhuan(m){
return m.split(',')
};
// Total coordinates , Starting and ending coordinates
var last = lineArr[0];
// Route polyline
var polyline = new AMap.Polyline({
map: this.map,
path: lineArr,
lineJoin: 'round',
strokeColor: color,
strokeOpacity: 1,
strokeWeight: 3,
strokeStyle: "solid"
});
this.map.add(polyline);
this.lineArrLx.push(polyline);
this.startMarker = new AMap.Marker({
map: this.map,
position: lineArr[0], // Latitude and longitude of the starting point
icon: new AMap.Icon({
size: new AMap.Size(25, 34),
image: require('@/assets/images/dir-marker.png'),
imageSize: new AMap.Size(135, 40),
imageOffset: new AMap.Pixel(-9, -3)
}), // The starting point ico
offset: new AMap.Pixel(-10, -30),
autoRotation: true,
});
this.endMarker = new AMap.Marker({
map: this.map,
position: lineArr[lineArr.length-1], // Latitude and longitude of the end point
icon: new AMap.Icon({
// Icon size
size: new AMap.Size(25, 34),
// The drawing address of the icon
image: require('@/assets/images/dir-marker.png'),
// The size of the picture used by the icon
imageSize: new AMap.Size(135, 40),
// Icon drawing offset
imageOffset: new AMap.Pixel(-95, -3)
}), // End ico
offset: new AMap.Pixel(-5, -30),
autoRotation: true,
});
this.map.add([this.startMarker,this.endMarker]);
},
xianGjMap(gwarry){
let that=this
gwarry.forEach(function(v,i) {
if(v.trajectory != null){
that.mpaxianGj(v.trajectory,v,'#0fcb14')
}
});
},
mpaxianGj(maplineArr,v,color){
// Coordinate set
let lineArrGj=[]
maplineArr.forEach(function(q,w) {
lineArrGj.push(onezhuan(q))
})
function onezhuan(m){
return m.split(',')
};
// Total coordinates , Starting and ending coordinates
var last = lineArrGj[0];
// Route polyline
var polylineGj = new AMap.Polyline({
map: this.map,
path: lineArrGj,
lineJoin: 'round',
strokeColor: color,
strokeOpacity: 1,
strokeWeight: 3,
strokeStyle: "solid"
});
this.map.add(polylineGj);
this.lineArrLxGj.push(polylineGj);
// Start and end
this.startMarkerGJ = new AMap.Marker({
map: this.map,
position: lineArrGj[0], // Latitude and longitude of the starting point
icon: new AMap.Icon({
size: new AMap.Size(32, 32),
image: require('@/assets/images/dir-car.png'),
imageSize: new AMap.Size(32, 32),
}),// The starting point ico
offset: new AMap.Pixel(0, 0),
autoRotation: true,
// angle:-90,
});
this.endMarkerGJ = new AMap.Marker({
map: this.map,
position: lineArrGj[lineArrGj.length-1], // Latitude and longitude of the end point
icon: new AMap.Icon({
// Icon size
size: new AMap.Size(32, 32),
// The drawing address of the icon
image: require('@/assets/images/dir-car.png'),
// The size of the picture used by the icon
imageSize: new AMap.Size(32, 32),
}), // End ico
offset: new AMap.Pixel(0, 0),
autoRotation: true,
});
this.map.add([this.startMarkerGJ,this.endMarkerGJ]);
},
}
};
![]()
边栏推荐
- Yushu A1 robot dog gesture control
- 如何在 pyqt 中实现桌面歌词
- Uncertainty of distributed energy - wind speed test (realized by matlab code)
- Compare kernelshap and treeshap based on speed, complexity and other factors
- HANA SQL 的Union和Union All
- 一道golang中关于for range常见坑的面试题
- Cmake learning
- 1063 Set Similarity
- UnauthorizedAccessException:Access to the path “/xx/xx.xx“ is denied
- googletest
猜你喜欢

Leetcode hot topic hot52-100

High numbers | calculation of double integral 4 | high numbers | handwritten notes

Cmake learning

TypeScript基础

Unity—3D数学-Vector3

Day109. Shangyitong: integrate Nacos, hospital list, drop-down list query, hospital online function, hospital details query

Basic knowledge of mobile phone testing

HANA SQL 的Union和Union All
![[attack and defense world web] difficulty four-star 12 point advanced question: flatscience](/img/fc/6648116f1bb47f1888035796fa5a58.png)
[attack and defense world web] difficulty four-star 12 point advanced question: flatscience

Compare kernelshap and treeshap based on speed, complexity and other factors
随机推荐
Cluster chat server: creation of project directory
High numbers | calculation of double integral 3 | high numbers | handwritten notes
The total ranking of blogs is 918
1063 Set Similarity
启牛是什么?请问一下手机开户股票开户安全吗?
Typescript Basics
集群聊天服务器:数据库表的设计
2022-7-23 12点 程序爱生活 小时线顶背离出现,保持下跌趋势,等待反弹信号出现。
[shader realizes roundwave circular ripple effect _shader effect Chapter 6]
[wechat applet] do you know about applet development?
OpenCV图像处理——拉普拉斯金字塔
Flink principle and development summary (detailed)
05_ UE4 advanced_ Material UV scaling
Minimum spanning tree: Kruskal
TypeScript基础
数据库压力测试方法小结
1061 Dating
合宙ESP32C3硬件配置信息串口打印輸出
Vite3 learning records
分布式能源的不确定性——风速测试(Matlab代码实现)