如何在openlayer接入矢量数据

先说矢量数据集接入,我们通过GeoJSON的示例代码(http://openlayers.org/en/latest/examples/geojson.html)了解Openlayers的源代码,确定显示要素绘制是调用ol.source.vector的forEachFeatureInExtent方法,所以我们根据ol.source.vector构建了ol.source.VectorMapZone,重写forEachFeatureInExtent方法,将查询结果转换成Openlayers3的Geometry和Feature,即可实现矢量数据集的接入

重写forEachFeatureInExtent方法

初始化ol.source.VectorMapZone,并做为数据源设置到Openlayers3的layer中

显示效果:

posted @ 2017-10-30 20:27  点滴珍贵,贵在积累  阅读(1589)  评论(0编辑  收藏  举报