|
@@ -22,52 +22,9 @@ |
|
@@ -22,52 +22,9 @@ |
22
|
min-height:767px;
|
22
|
min-height:767px;
|
23
|
}
|
23
|
}
|
24
|
</style>
|
24
|
</style>
|
25
|
- <script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp"></script>
|
|
|
26
|
- <script>
|
|
|
27
|
- var markersArray=[];
|
|
|
28
|
- var init = function() {
|
|
|
29
|
- var map = new qq.maps.Map(document.getElementById("container"),{
|
|
|
30
|
- center: new qq.maps.LatLng(39.916527,116.397128),
|
|
|
31
|
- zoom: 13,
|
|
|
32
|
- });
|
|
|
33
|
- //添加监听事件
|
|
|
34
|
- qq.maps.event.addListener(map, 'click', function(data) {
|
|
|
35
|
-
|
|
|
36
|
- for (i in markersArray) {
|
|
|
37
|
- markersArray[i].setMap(null);
|
|
|
38
|
- }
|
|
|
39
|
-
|
|
|
40
|
- var anchor = new qq.maps.Point(6, 6),
|
|
|
41
|
- size = new qq.maps.Size(24, 24),
|
|
|
42
|
- origin = new qq.maps.Point(0, 0),
|
|
|
43
|
- marker = new qq.maps.Marker({
|
|
|
44
|
- map: map,
|
|
|
45
|
- position:data.latLng});
|
|
|
46
|
- markersArray.push(marker);
|
|
|
47
|
- console.log(data);
|
|
|
48
|
- document.getElementById('pointInput').value=data.latLng;
|
|
|
49
|
- setTimeout(function(){
|
|
|
50
|
- // alert(data.latLng);
|
|
|
51
|
- },200);
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
- });
|
|
|
55
|
- }
|
|
|
56
|
-
|
|
|
57
|
|
25
|
|
58
|
- function confirmSelect(){
|
|
|
59
|
- var selectLocation = {};
|
|
|
60
|
- var gpsAddr = document.getElementById('currentAddr');
|
|
|
61
|
- var location = document.getElementById('pointInput');
|
|
|
62
|
- /* selectLocation.gpsAddr = gpsAddr.innerHTML;*/
|
|
|
63
|
- selectLocation.location = location.value;
|
|
|
64
|
- console.log(selectLocation.location);
|
|
|
65
|
- window.opener.SelectLocation.selectCallback(selectLocation);
|
|
|
66
|
- window.close();
|
|
|
67
|
- }
|
|
|
68
|
- </script>
|
|
|
69
|
</head>
|
26
|
</head>
|
70
|
-<body onload="init()">
|
27
|
+<body onload="">
|
71
|
<div class="LogoCon clear" style="font-size:18px;">
|
28
|
<div class="LogoCon clear" style="font-size:18px;">
|
72
|
|
29
|
|
73
|
<div style="display:block">
|
30
|
<div style="display:block">
|
|
@@ -78,5 +35,136 @@ |
|
@@ -78,5 +35,136 @@ |
78
|
</div>
|
35
|
</div>
|
79
|
</div>
|
36
|
</div>
|
80
|
<div id="container"></div>
|
37
|
<div id="container"></div>
|
|
|
38
|
+<!--<div id="searchPart">-->
|
|
|
39
|
+ <!--<input type="text" id="searchInput" placeholder="请输入">-->
|
|
|
40
|
+ <!--<button id="searchBtn">搜索</button>-->
|
|
|
41
|
+<!--</div>-->
|
81
|
</body>
|
42
|
</body>
|
|
|
43
|
+
|
|
|
44
|
+<script src="https://map.qq.com/api/gljs?v=1.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77"></script>
|
|
|
45
|
+<!--<script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp"></script>-->
|
|
|
46
|
+<script>
|
|
|
47
|
+ // var markersArray=[];
|
|
|
48
|
+ // var init = function() {
|
|
|
49
|
+ // var map = new qq.maps.Map(document.getElementById("container"),{
|
|
|
50
|
+ // center: new qq.maps.LatLng(39.916527,116.397128),
|
|
|
51
|
+ // zoom: 13,
|
|
|
52
|
+ // });
|
|
|
53
|
+ // //添加监听事件
|
|
|
54
|
+ // qq.maps.event.addListener(map, 'click', function(data) {
|
|
|
55
|
+ //
|
|
|
56
|
+ // for (i in markersArray) {
|
|
|
57
|
+ // markersArray[i].setMap(null);
|
|
|
58
|
+ // }
|
|
|
59
|
+ //
|
|
|
60
|
+ // var anchor = new qq.maps.Point(6, 6),
|
|
|
61
|
+ // size = new qq.maps.Size(24, 24),
|
|
|
62
|
+ // origin = new qq.maps.Point(0, 0),
|
|
|
63
|
+ // marker = new qq.maps.Marker({
|
|
|
64
|
+ // map: map,
|
|
|
65
|
+ // position:data.latLng});
|
|
|
66
|
+ // markersArray.push(marker);
|
|
|
67
|
+ // console.log(data);
|
|
|
68
|
+ // document.getElementById('pointInput').value=data.latLng;
|
|
|
69
|
+ // setTimeout(function(){
|
|
|
70
|
+ // // alert(data.latLng);
|
|
|
71
|
+ // },200);
|
|
|
72
|
+ //
|
|
|
73
|
+ //
|
|
|
74
|
+ // });
|
|
|
75
|
+ // }
|
|
|
76
|
+
|
|
|
77
|
+ var map, marker, infoWindow;
|
|
|
78
|
+ // 创建信息窗口
|
|
|
79
|
+
|
|
|
80
|
+
|
|
|
81
|
+
|
|
|
82
|
+
|
|
|
83
|
+
|
|
|
84
|
+ var center = new TMap.LatLng(39.984104, 116.307503);//设置中心点坐标
|
|
|
85
|
+ //初始化地图
|
|
|
86
|
+ var map = new TMap.Map("container", {
|
|
|
87
|
+ center: center
|
|
|
88
|
+ });
|
|
|
89
|
+
|
|
|
90
|
+ //初始化marker图层
|
|
|
91
|
+ var markerLayer = new TMap.MultiMarker({
|
|
|
92
|
+ id: 'marker-layer',
|
|
|
93
|
+ map: map
|
|
|
94
|
+ });
|
|
|
95
|
+
|
|
|
96
|
+ //监听点击事件添加marker
|
|
|
97
|
+ map.on("click", (evt) => {
|
|
|
98
|
+
|
|
|
99
|
+
|
|
|
100
|
+ console.log(evt.latLng);
|
|
|
101
|
+ document.getElementById('pointInput').value=evt.latLng
|
|
|
102
|
+
|
|
|
103
|
+ });
|
|
|
104
|
+
|
|
|
105
|
+ function searchClick() {
|
|
|
106
|
+ let searchInput = document.getElementById('searchInput').value; // 获取搜索内容
|
|
|
107
|
+ let url = [
|
|
|
108
|
+ 'https://apis.map.qq.com/ws/place/v1/search',
|
|
|
109
|
+ '?boundary=nearby(39.984104,116.307503,1000,0)',
|
|
|
110
|
+ `&keyword=${searchInput}`,
|
|
|
111
|
+ '&page_size=10&page_index=1&orderby=_distance',
|
|
|
112
|
+ '&output=jsonp&callback=cb',
|
|
|
113
|
+ '&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77'
|
|
|
114
|
+ ].join('');
|
|
|
115
|
+ jsonp_request(url);
|
|
|
116
|
+ infoWindow.close(); // 关闭信息窗口
|
|
|
117
|
+ }
|
|
|
118
|
+ // 添加搜索按钮点击事件
|
|
|
119
|
+ const searchBtn = document.getElementById('searchBtn');
|
|
|
120
|
+ searchBtn.addEventListener('click', searchClick, false);
|
|
|
121
|
+
|
|
|
122
|
+ function jsonp_request(url) {
|
|
|
123
|
+ let script = document.createElement('script');
|
|
|
124
|
+ script.src = url;
|
|
|
125
|
+ document.body.appendChild(script);
|
|
|
126
|
+ }
|
|
|
127
|
+
|
|
|
128
|
+ function confirmSelect(){
|
|
|
129
|
+ var selectLocation = {};
|
|
|
130
|
+ var gpsAddr = document.getElementById('currentAddr');
|
|
|
131
|
+ var location = document.getElementById('pointInput');
|
|
|
132
|
+ /* selectLocation.gpsAddr = gpsAddr.innerHTML;*/
|
|
|
133
|
+ selectLocation.location = location.value;
|
|
|
134
|
+ console.log(selectLocation.location);
|
|
|
135
|
+ window.opener.SelectLocation.selectCallback(selectLocation);
|
|
|
136
|
+ window.close();
|
|
|
137
|
+ }
|
|
|
138
|
+
|
|
|
139
|
+
|
|
|
140
|
+ function cb(ret) {
|
|
|
141
|
+ let newBounds = new TMap.LatLngBounds();
|
|
|
142
|
+ let markerArr = [];
|
|
|
143
|
+ if(ret && ret.status===0 && ret.data.length>0) {
|
|
|
144
|
+ // 将搜索结果保存进数组中
|
|
|
145
|
+ ret.data.forEach( (item, index) => {
|
|
|
146
|
+ let position = new TMap.LatLng(item.location.lat, item.location.lng);
|
|
|
147
|
+ markerArr.push({
|
|
|
148
|
+ position: position,
|
|
|
149
|
+ properties: {
|
|
|
150
|
+ title: item.title,
|
|
|
151
|
+ address: item.address,
|
|
|
152
|
+ tel: item.tel!==' ' ? item.tel : '暂无'
|
|
|
153
|
+ }
|
|
|
154
|
+ });
|
|
|
155
|
+ // 寻找搜索结果的边界
|
|
|
156
|
+ newBounds.extend(position);
|
|
|
157
|
+ });
|
|
|
158
|
+ // 更新marker层,显示标记
|
|
|
159
|
+ marker.setGeometries(markerArr);
|
|
|
160
|
+ // 地图自适应边界
|
|
|
161
|
+ map.fitBounds(newBounds, {
|
|
|
162
|
+ padding: 100 // 边界与内容之间留的间距
|
|
|
163
|
+ });
|
|
|
164
|
+ }
|
|
|
165
|
+ }
|
|
|
166
|
+
|
|
|
167
|
+
|
|
|
168
|
+
|
|
|
169
|
+</script>
|
82
|
</html> |
170
|
</html> |