xq-csg-weapp_uni-ts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.9KB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8" />
  5. <script>
  6. var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
  7. CSS.supports('top: constant(a)'))
  8. document.write(
  9. '<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
  10. (coverSupport ? ', viewport-fit=cover' : '') + '" />')
  11. </script>
  12. <title></title>
  13. <!--preload-links-->
  14. <!--app-context-->
  15. <script src="https://webapi.amap.com/maps?v=1.4.15&key=a24126d522c5dedb7791207742b6360b"></script>
  16. <script type="text/javascript">
  17. //初始化地图时,若center属性缺省,地图默认定位到用户所在城市的中心
  18. var map = new AMap.Map('container', {
  19. resizeEnable: true
  20. });
  21. AMap.plugin('AMap.Geolocation', function() {
  22. var geolocation = new AMap.Geolocation({
  23. enableHighAccuracy: true,//是否使用高精度定位,默认:true
  24. timeout: 10000, //超过10秒后停止定位,默认:5s
  25. buttonPosition:'RB', //定位按钮的停靠位置
  26. buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
  27. zoomToAccuracy: true, //定位成功后是否自动调整地图视野到定位点
  28. });
  29. map.addControl(geolocation);
  30. geolocation.getCurrentPosition(function(status,result){
  31. console.log(status,result);
  32. if(status=='complete'){
  33. console.log("result",result);
  34. window.localStorage.setItem('userLocation',result.position.lng+','+result.position.lat)
  35. }
  36. });
  37. });
  38. </script>
  39. </head>
  40. <body>
  41. <div id="app"><!--app-html--></div>
  42. <div id="container"></div>
  43. <script type="module" src="/src/main.ts"></script>
  44. </body>
  45. </html>