正在显示
1 个修改的文件
包含
59 行增加
和
24 行删除
@@ -199,12 +199,13 @@ | @@ -199,12 +199,13 @@ | ||
199 | </div> | 199 | </div> |
200 | </body> | 200 | </body> |
201 | </html> | 201 | </html> |
202 | -<script type="text/javascript" src = 'https://webapi.amap.com/maps?v=1.4.4&test=true&key=ef53760bd959a4df08b7d4587280e642&&plugin=AMap.ToolBar,AMap.IndoorMap'></script> | ||
203 | <script type="text/javascript" src="../../assets/js/api.js"></script> | 202 | <script type="text/javascript" src="../../assets/js/api.js"></script> |
204 | <script type="text/javascript" src="../../assets/js/swiper-3.4.2.min.js"></script> | 203 | <script type="text/javascript" src="../../assets/js/swiper-3.4.2.min.js"></script> |
205 | <script type="text/javascript" src="../../assets/js/weui.min.js"></script> | 204 | <script type="text/javascript" src="../../assets/js/weui.min.js"></script> |
206 | <script type="text/javascript" src="../../assets/js/public.js"></script> | 205 | <script type="text/javascript" src="../../assets/js/public.js"></script> |
207 | <script type="text/javascript" src="../../assets/js/fastclick.js"></script> | 206 | <script type="text/javascript" src="../../assets/js/fastclick.js"></script> |
207 | +<script type="text/javascript" src = 'https://webapi.amap.com/maps?v=1.4.4&test=true&key=ef53760bd959a4df08b7d4587280e642&&plugin=AMap.ToolBar,AMap.IndoorMap'></script> | ||
208 | + | ||
208 | <script> | 209 | <script> |
209 | new FastClick(document.body); | 210 | new FastClick(document.body); |
210 | </script> | 211 | </script> |
@@ -288,31 +289,65 @@ | @@ -288,31 +289,65 @@ | ||
288 | }) | 289 | }) |
289 | }, | 290 | }, |
290 | // 定位当前城市 | 291 | // 定位当前城市 |
291 | - get_city: function () { | ||
292 | - app.map = new AMap.Map('container', {}); | ||
293 | - app.map.plugin('AMap.Geolocation', function () { | ||
294 | - var geolocation = new AMap.Geolocation({ | ||
295 | - // 是否使用高精度定位,默认: | ||
296 | - enableHighAccuracy: true, | ||
297 | - // 设置定位超时时间,默认:无穷大 | ||
298 | - timeout: 10000, | ||
299 | - }); | ||
300 | - geolocation.getCurrentPosition(); | ||
301 | - AMap.event.addListener(geolocation, 'complete', onComplete) | ||
302 | - AMap.event.addListener(geolocation, 'error', onError) | 292 | + get_city: function() { |
293 | + var app = this ; | ||
294 | + map = new AMap.Map('container', {}); | ||
295 | + map.plugin('AMap.Geolocation', function() { | ||
296 | + var geolocation = new AMap.Geolocation({ | ||
297 | + // 是否使用高精度定位,默认:true | ||
298 | + enableHighAccuracy: true, | ||
299 | + // 设置定位超时时间,默认:无穷大 | ||
300 | + timeout: 10000 | ||
301 | + }); | ||
302 | + geolocation.getCurrentPosition(); | ||
303 | + AMap.event.addListener(geolocation, 'complete', onComplete) | ||
304 | + AMap.event.addListener(geolocation, 'error', onError) | ||
305 | + function onComplete(data) { | ||
306 | + // app.cityname = data.addressComponent.province; | ||
307 | + console.log(app.cityname); | ||
308 | + app.lng = data.position.lng; | ||
309 | + app.lat = data.position.lat; | ||
310 | + app.street = data.addressComponent.street; | ||
311 | + // console.log(app.lng); | ||
312 | + // console.log(app.lat); | ||
313 | + // | ||
314 | + // // 获取附近地址 | ||
315 | + // app.map = new AMap.Map('container', {}); | ||
316 | + // AMap.service(["AMap.PlaceSearch"], function() { | ||
317 | + // var placeSearch = new AMap.PlaceSearch({ | ||
318 | + // pageSize: 10, // 每页10条 | ||
319 | + // pageIndex: 1, // 获取第一页 | ||
320 | + // city: app.cityname // 指定城市名(如果你获取不到城市名称,这个参数也可以不传,注释掉) | ||
321 | + // }); | ||
322 | + // | ||
323 | + // // 第一个参数是关键字,这里传入的空表示不需要根据关键字过滤 | ||
324 | + // // 第二个参数是经纬度,数组类型 | ||
325 | + // // 第三个参数是半径,周边的范围 | ||
326 | + // // 第四个参数为回调函数 | ||
327 | + // | ||
328 | + // placeSearch.searchNearBy(app.cityname, [app.lng, app.lat], 1000, function(status, result) { | ||
329 | + // | ||
330 | + // console.log(JSON.stringify(status)) | ||
331 | + // if(result.info === 'OK') { | ||
332 | + // var locationList = result.poiList.pois; // 周边地标建筑列表 | ||
333 | + // console.log(locationList) | ||
334 | + // app.nearList = locationList // 生成地址列表html | ||
335 | + // // createLocationHtml(locationList); | ||
336 | + // } else { | ||
337 | + // console.log('获取位置信息失败!'); | ||
338 | + // } | ||
339 | + // }); | ||
340 | + // }); | ||
341 | + } | ||
303 | 342 | ||
304 | - function onComplete(data) { | ||
305 | - console.log(JSON.stringify(data)) | ||
306 | - app.cityname = data.addressComponent.province | ||
307 | - // data是具体的定位信息 | ||
308 | - } | 343 | + function onError(erro) { |
344 | + console.log(erro) | ||
345 | + // 定位出错 | ||
346 | + toastMsg('请开启定位功能') | ||
347 | + } | ||
348 | + }) | ||
349 | + }, | ||
309 | 350 | ||
310 | - function onError(erro) { | ||
311 | - // 定位出错 | ||
312 | - toastMsg('请开启定位功能') | ||
313 | - } | ||
314 | - }) | ||
315 | - }, | ||
316 | // 切换底部导航 | 351 | // 切换底部导航 |
317 | changeTab: function (res) { | 352 | changeTab: function (res) { |
318 | //跳转页面 | 353 | //跳转页面 |
-
请 注册 或 登录 后发表评论