| | |
| | | import { map, satellite, controlbar } from './index_old'; |
| | | // import '@/lib/jquery-3.5.1.min'; |
| | | |
| | | /** |
| | | * 坐标拾取鼠标点击回调事件 |
| | | */ |
| | | var _locationMarker, _locationText; |
| | | function _coorPickListener(e) { |
| | | var text = `经度: ${e.lnglat.getLng()}<br/>纬度: ${e.lnglat.getLat()}`; |
| | | if (_locationMarker == undefined) { |
| | | var textM = new AMap.Text({ |
| | | style: { |
| | | 'font-size': '12px' |
| | | }, |
| | | text: text, |
| | | position: e.lnglat, |
| | | offset: new AMap.Pixel(0, 30) |
| | | }); |
| | | |
| | | var marker = new AMap.Marker({ |
| | | position: e.lnglat |
| | | // icon: icon, |
| | | // anchor: 'top-center', |
| | | // content: '<i class="fa fa-map-marker fa-2x" style="color: #E6DB06;" aria-hidden="true"></i>' |
| | | }); |
| | | map.add(marker); |
| | | map.add(textM); |
| | | _locationMarker = marker; |
| | | _locationText = textM; |
| | | } else { |
| | | _locationMarker.setPosition(e.lnglat); |
| | | _locationText.setPosition(e.lnglat); |
| | | _locationText.setText(text); |
| | | } |
| | | } |
| | | |
| | | export default { |
| | | /** |
| | | * 开关地物标注 |
| | | * @param {boolean} value |
| | | */ |
| | | toggleFeatures: (value) => { |
| | | toggleFeatures(value) { |
| | | value ? map.setFeatures(['bg', 'road', 'point', 'building']) : map.setFeatures(['bg', 'road']); |
| | | }, |
| | | |
| | | /** |
| | | * 开关卫星地图 |
| | | * @param {boolean} value |
| | | */ |
| | | toggleSatellite: (value) => { |
| | | toggleSatellite(value) { |
| | | value ? satellite.show() : satellite.hide(); |
| | | }, |
| | | |
| | | /** |
| | | * 开关控制罗盘 |
| | | * @param {boolean} value |
| | | */ |
| | | toggleControlbar: (value) => { |
| | | toggleControlbar(value) { |
| | | // value ? controlbar.show() : controlbar.hide(); |
| | | value ? $('.amap-controlbar').show() : $('.amap-controlbar').hide(); |
| | | }, |
| | | |
| | | /** |
| | | * 开关坐标拾取 |
| | | * @param {boolean} value |
| | | */ |
| | | toggleCoorPicking(value) { |
| | | if (value) { |
| | | map.on('click', _coorPickListener); |
| | | } else { |
| | | map.off('click', _coorPickListener); |
| | | map.remove([_locationMarker, _locationText]); |
| | | _locationMarker = undefined; |
| | | _locationText = undefined; |
| | | } |
| | | } |
| | | }; |