openlayers:实现为每个线段绘制箭头
为每个线段绘制箭头的示例。
main.js
import Draw from 'ol/interaction/Draw.js';
import Map from 'ol/Map.js';
import Point from 'ol/geom/Point.js';
import View from 'ol/View.js';
import {Icon, Stroke, Style} from 'ol/style.js';
import {OSM, Vector as VectorSource} from 'ol/source.js';
import {Tile as TileLayer, Vector as VectorLayer} from 'ol/layer.js';
import {get} from 'ol/proj.js';
const raster = new TileLayer({
source: new OSM(),
});
const source = new VectorSource();
const styleFunction = function (feature) {
const geometry = feature.getGeometry();
const styles = [
// linestring
new Style({
stroke: new Stroke({
color: