const Magix = require('magix'); const View = require('dmp-new/view') require('amap') Magix.applyStyle('@./lbs.less') module.exports = View.extend({ tmpl: '@map.html', init(options) { this.options = options }, render() { const locations = this.options.locations this.updater.digest({ locations }) if (locations.length > 1 || locations.length === 0) { return } const center = locations[0].split(':')[1].split('*') const map = new AMap.Map(`${this.id}_shopMap`, { resizeEnable: true, center, zoom: 15 }); const marker = new AMap.Marker({ icon: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png", position: center }); map.add(marker) if (this.options.currentRadius && this.options.radiusType == '2') { let radius = parseFloat(this.options.currentRadius) * 1000 const circle = new AMap.Circle({ center: new AMap.LngLat(center[0], center[1]), // 圆心位置 radius, //半径 strokeColor: "#839cdc", //线颜色 strokeOpacity: 1, //线透明度 strokeWeight: 2, //线粗细度 fillColor: "#839cdc", //填充颜色 fillOpacity: 0.25 //填充透明度 }); map.add(circle) } } });