* @private * @function WebMap.prototype.createDataflowService * @description 将feature添加到数据流图层 * @param {Object} layerInfo - 图层参数 * @param {Object} callback - 回调函数
(layerInfo, callback)
| 4137 | * @param {Object} callback - 回调函数 |
| 4138 | */ |
| 4139 | createDataflowService(layerInfo, callback) { |
| 4140 | let that = this; |
| 4141 | let dataflowService = new DataFlowService(layerInfo.wsUrl).initSubscribe(); |
| 4142 | dataflowService.on('messageSucceeded', function (e) { |
| 4143 | let geojson = JSON.parse(e.value.data); |
| 4144 | let feature = transformTools.readFeature(geojson, { |
| 4145 | dataProjection: layerInfo.projection || 'EPSG:4326', |
| 4146 | featureProjection: that.baseProjection || 'EPSG:4326' |
| 4147 | }); |
| 4148 | feature.setProperties({ attributes: geojson.properties }); |
| 4149 | callback(feature); |
| 4150 | }); |
| 4151 | layerInfo.dataflowService = dataflowService; |
| 4152 | } |
| 4153 | |
| 4154 | /** |
| 4155 | * @private |
no test coverage detected