map.vue 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view class="page-section page-section-gap">
  3. <map style="width: 100%; height: 218upx;" :latitude="latitude" :longitude="longitude"></map>
  4. <!-- <map id="map" style="width: 100%; height: 300px;" :latitude="latitude" :longitude="longitude" :markers="covers"> -->
  5. <!-- </map> -->
  6. </view>
  7. </template>
  8. <script>
  9. // import AMapLoader from '@amap/amap-jsapi-loader';
  10. // window._AMapSecurityConfig = {
  11. // securityJsCode: "d62687dd438cfadd859bbab66d8e41a2",
  12. // };
  13. export default {
  14. data() {
  15. return {
  16. map: null,
  17. marker: null,
  18. id:0, // 使用 marker点击事件 需要填写id
  19. title: 'map',
  20. latitude: 39.909,
  21. longitude: 116.39742,
  22. covers: [{
  23. latitude: 39.909,
  24. longitude: 116.39742,
  25. iconPath: '../../../static/location.png'
  26. }, {
  27. latitude: 39.90,
  28. longitude: 116.39,
  29. iconPath: '../../../static/location.png'
  30. }]
  31. };
  32. },
  33. onReady() {
  34. // this.initMap();
  35. },
  36. methods: {
  37. // initMap() {
  38. // console.log(222);
  39. // AMapLoader.load({
  40. // key: "18c5a399a406896c5aa53d808e401294", // 申请好的Web端开发者Key,首次调用 load 时必填
  41. // version: '2.0', // 指定要加载的API的版本号,默认为 1.4.15
  42. // }).then((AMap) => {
  43. // this.map = new AMap.Map('amap', {
  44. // zoom: 11, // 初始化地图层级
  45. // center: [116.397428, 39.90923], // 初始化地图中心点位置
  46. // });
  47. // // this.map.on('click', (e) => {
  48. // // lngLatLng.value = e.lnglat.lng;
  49. // // lngLatLat.value = e.lnglat.lat;
  50. // // console.log(lngLatLng.value, lngLatLat.value);
  51. // // // positionArr.value = [lngLatLng.value, lngLatLat.value]
  52. // // // addressValue.value = ""
  53. // // // if (marker.value) {
  54. // // // marker.value.setPosition([lngLatLng.value, lngLatLat.value]); // 更新Marker位置
  55. // // // }
  56. // // // this.emit('back', positionArr.value)
  57. // // })
  58. // // let auto = new AMap.AutoComplete({
  59. // // city: "太原市", // 限定城市,默认全国
  60. // // input: "search_input",
  61. // // })
  62. // // let placeSearch = new AMap.PlaceSearch({
  63. // // city: "太原市",
  64. // // map: this.map
  65. // // });
  66. // // // 标点位置
  67. // // marker.value = new AMap.Marker({
  68. // // position: [113.392517, 22.517024], //经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
  69. // // map: this.map, // 当操作完成时,应该将结果展示在哪个地图上
  70. // // })
  71. // // map.add(marker)
  72. // }).catch(e => {
  73. // console.error(e);
  74. // });
  75. // }
  76. }
  77. }
  78. </script>
  79. <style scoped>
  80. .content {
  81. display: flex;
  82. justify-content: center;
  83. align-items: center;
  84. }
  85. </style>