-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgaode.html
102 lines (97 loc) · 3.35 KB
/
gaode.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
<title>地图显示</title>
<style>
html,
body,
#container {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="container"></div>
<!-- 加载地图JSAPI脚本 -->
<!-- 加载qwebchannel -->
<script type="text/javascript" src="./qwebchannel.js"></script>
<script src="https://webapi.amap.com/maps?v=1.4.15&key=e37dd1e906472f9150542c9ccc7724ae"></script>
<script>
// var mapOpts = {
// showIndoorMap: false, // 是否在有矢量底图的时候自动展示室内地图,PC默认true,移动端默认false
// resizeEnable: true, //是否监控地图容器尺寸变化,默认值为false
// dragEnable: false, // 地图是否可通过鼠标拖拽平移,默认为true
// keyboardEnable: false, //地图是否可通过键盘控制,默认为true
// doubleClickZoom: false, // 地图是否可通过双击鼠标放大地图,默认为true
// zoomEnable: false, //地图是否可缩放,默认值为true
// rotateEnable: false, // 地图是否可旋转,3D视图默认为true,2D视图默认false
// }
var path=[];//存储目标点的数组
var marker,map = new AMap.Map('container', {
keyboardEnable: false, //地图是否可通过键盘控制,默认为true
resizeEnable: true, //是否监控地图容器尺寸变化
zoom:13 //初始化地图层级
});//地图
var polyl = new AMap.Polyline({
// path: path,
isOutline: true,
outlineColor: '#ffeeff',
borderWeight: 1,
strokeColor: "#ff0000",
strokeStyle: "solid",
lineJoin: 'round',
lineCap: 'round',
strokeWeight: 8,
showDir:true,
});//折线
// 构造官方卫星图层
var satelliteLayer = new AMap.TileLayer.Satellite();
// 加入卫星图层
map.add(satelliteLayer);
//绑定鼠标点击事件
map.on('click', onClick);
//点击事件
//添加 marker
function addMarker(lng,lat) {
marker = new AMap.Marker({
position: [lng, lat],
});
marker.setMap(map);
}
//清除所有标记
function clearAll() {
map.clearMap();//清空地图标记
path = [];//清空路径信息
}
//新建QWebChannel对象实例,使之能与c++函数通信
new QWebChannel(qt.webChannelTransport,
function (channel) {
var pointxy = channel.objects.pointxy;
window.foo = pointxy;
//相当于监听这个信号,一有对应的信号收到,调用函数处理
pointxy.mapCenterChanged.connect(setmapcenter);
}
);
var setmapcenter=function(data1,data2)
{
var Lng=data1;
var Lat=data2;
map.setCenter([Lng,Lat]);
}
function onClick(e) {
var my_coordinate = [e.lnglat.Q , e.lnglat.P];
path.push(my_coordinate);
polyl.setPath(path);
polyl.setMap(map);
addMarker(e.lnglat.Q,e.lnglat.P);
// JS调用QT
window.foo.saveMapPoint(e.lnglat.Q,e.lnglat.P);
};
</script>
</body>
</html>