openlayers 文字竖直显示

image.png
 const startPoint = [132, 28];
      const style = new ol.style.Style({
        text: new ol.style.Text({
          font: "bold 14px Calibri,sans-serif",
          scale: 1,
          text: "",
          fill: new ol.style.Fill({ color: "green" }),
        }),
      });
      ["48", "小", "时", "警", "戒", "线"].forEach((item, index) => {
        const feature = new ol.Feature({
          geometry: new ol.geom.Point([startPoint[0], startPoint[1] - index * 0.1]),
        });
        const st = style.clone();
        st.getText().setText(item);
        feature.setStyle(st);
        source.addFeature(feature);
      });

      const feature = new ol.Feature({
        geometry: new ol.geom.Point([startPoint[0] + 0.2, startPoint[1]]),
      });
      const st = style.clone();
      st.getText().setText("24\n小\n时\n警\n戒\n线");
      feature.setStyle(st);
      source.addFeature(feature);

你可能感兴趣的:(openlayers 文字竖直显示)