zoukankan      html  css  js  c++  java
  • Arcgisapi for js 4.x生成点线面并加载到地图上

    1.点
    const point = {//点的坐标信息
    type: "point",
    longitude: -49.97,
    latitude: 41.73
    };
    const markerSymbol = {//点的样式
    type: "simple-marker",
    color: [226, 119, 40],
    outline: {
    color: [255, 255, 255],
    2
    }
    };
    const pointGraphic = new Graphic({//创建点图斑对象
    geometry: point,
    symbol: markerSymbol
    });
    2.线
    const polyline = {//线的坐标信息
    type: "polyline", // autocasts as new Polyline()
    paths: [[-111.3, 52.68], [-98, 49.5], [-93.94, 29.89]]
    };
    const lineSymbol = {//线的样式
    type: "simple-line",
    color: [226, 119, 40],
    4
    };
    const lineAtt = {//线的属性
    Name: "Keystone Pipeline",
    Owner: "TransCanada",
    Length: "3,456 km"
    };
    const polylineGraphic = new Graphic({//创建线图斑对象并且绑定属性以及弹出框信息
    geometry: polyline,
    symbol: lineSymbol,
    attributes: lineAtt,
    popupTemplate: {
    title: "{Name}",
    content: [
    {
    type: "fields",
    fieldInfos: [
    {
    fieldName: "Name"
    },
    {
    fieldName: "Owner"
    },
    {
    fieldName: "Length"
    }
    ]
    }
    ]
    }
    });
    3.面
    const polygon = {//面的坐标信息
    type: "polygon",
    rings: [[-64.78, 32.3], [-66.07, 18.45], [-80.21, 25.78], [-64.78, 32.3]]
    };
    const fillSymbol = {//面的样式
    type: "simple-fill",
    color: [227, 139, 79, 0.8],
    outline: {
    // autocasts as new SimpleLineSymbol()
    color: [255, 255, 255],
    1
    }
    };
    const polygonGraphic = new Graphic({//创建面图斑
    geometry: polygon,
    symbol: fillSymbol
    });

    4.将上面创建的Graphic加入到地图
    第一中方式:view.graphics.addMany([pointGraphic, polylineGraphic, polygonGraphic]);
    第二种方式: let graphicLayer = GraphicsLayer();
    graphicLayer.addMany[pointGraphic, polylineGraphic, polygonGraphic]
    graphicLayer.markId = "xxx";
    view.map.add(graphicLayer);

  • 相关阅读:
    git rebase命令
    java中HashSet对象内的元素的hashCode值不能变化
    Spring中WebApplicationInitializer的理解
    mysql判断表字段或索引是否存在,然后修改
    mysql存储过程
    判断地图上的点是否在圆形,多边形,区域内
    计算任意多边形的面积、中心、重心
    判断点是否在任意多边形内
    springMvc将对象json返回时自动忽略掉对象中的特定属性的注解方式
    String.format()详细用法
  • 原文地址:https://www.cnblogs.com/maycpou/p/14793061.html
Copyright © 2011-2022 走看看