(id, type, opt)
| 3026 | |
| 3027 | var MapHelper = function () { |
| 3028 | function MapHelper(id, type, opt) { |
| 3029 | classCallCheck(this, MapHelper); |
| 3030 | |
| 3031 | if (!id || !type) { |
| 3032 | console.warn('id 和 type 为必填项'); |
| 3033 | return false; |
| 3034 | } |
| 3035 | |
| 3036 | if (type == 'baidu') { |
| 3037 | if (!BMap) { |
| 3038 | console.warn('请先引入百度地图JS API'); |
| 3039 | return false; |
| 3040 | } |
| 3041 | } else { |
| 3042 | console.warn('暂不支持你的地图类型'); |
| 3043 | } |
| 3044 | this.type = type; |
| 3045 | var center = opt && opt.center ? opt.center : [106.962497, 38.208726]; |
| 3046 | var zoom = opt && opt.zoom ? opt.zoom : 5; |
| 3047 | var map = this.map = new BMap.Map(id, { |
| 3048 | enableMapClick: false |
| 3049 | }); |
| 3050 | map.centerAndZoom(new BMap.Point(center[0], center[1]), zoom); |
| 3051 | map.enableScrollWheelZoom(true); |
| 3052 | |
| 3053 | map.setMapStyle({ |
| 3054 | style: 'light' |
| 3055 | }); |
| 3056 | } |
| 3057 | |
| 3058 | createClass(MapHelper, [{ |
| 3059 | key: 'addLayer', |
nothing calls this directly
no test coverage detected