zoukankan      html  css  js  c++  java
  • openlayers根据x,y坐标加载点到地图上

    1.比如一个有三个点的对象

    let obj = [[1,1],[2,2],[3,3]];

    2.用这三个点的坐标生成一个图层加载到地图上

    let features = new Array();
        for (let i = 0; i < obj .length; i++) {
          let point = new Point([obj [i][0], obj[i][1]]);
          features.push(new Feature(point));
        }
        let source = new VectorSource({
          features: features,
        });
        let vectorLayer = new VectorLayer({
          source: source,
          style:
            function (feature) {
              return new Style({
                image: new CircleStyle({
                  radius: 5,
                  fill: new Fill({//面的填充
                    color: 'rgba(0, 0, 255)',
                  }),
                  stroke: new Stroke({ color: 'red',  1 }),
                })
              })
            }
        });
        this.map.addLayer(vectorLayer);
    3.ol引入:
    import Point from 'ol/geom/Point';
    import Feature from 'ol/Feature';
    import VectorLayer from 'ol/layer/Vector';
    import VectorSource from 'ol/source/Vector';
    import { Stroke, Style, Icon, Text as TextStyle, Circle as CircleStyle, Fill } from 'ol/style.js';
  • 相关阅读:
    Yarn的运行原理(执行流程)
    Hive 表类型简述
    hive 表类型
    Hadoop小知识点总结1
    电商交易项目案例
    乘用车辆和商用车辆销售数据分析
    搜狗搜索日志分析系统
    mysql group by 对多个字段进行分组
    group by
    输出GPLT
  • 原文地址:https://www.cnblogs.com/maycpou/p/14572747.html
Copyright © 2011-2022 走看看