【问题标题】:"Type '{ type: string; longitude: number; latitude: number; }' has no properties in common with type 'GeometryProperties'." error on angular 11“类型 '{ 类型:字符串;经度:数字;纬度:数字;}' 与类型 'GeometryProperties' 没有共同的属性。”角度 11 上的错误
【发布时间】:2021-06-02 09:46:32
【问题描述】:

我遵循“https://github.com/Esri/jsapi-resources/tree/master/esm-samples/jsapi-angular-cli”上的每条说明,并尝试使用以下 sn- 在地图上添加一个点- p.

const graphicsLayer = new GraphicsLayer();
sMap.add(graphicsLayer);

var point = {
            type: "point",  
            longitude: -71.2643,
            latitude: 42.0909
        };
        const simpleMarkerSymbol = {
            type: "simple-marker",
            color: [226, 119, 40],  
            outline: {
                color: [255, 255, 255], 
                width: 1
            }
        };

        
        const pointGraphic = new Graphic({
            geometry:point,
            symbol: simpleMarkerSymbol
        });

 graphicsLayer.add(pointGraphic);

但我得到了这个 类型 '{ 类型:字符串;经度:数字;纬度:数字; }' 与类型 'GeometryProperties' 没有共同的属性 错误。我不知道为什么。

【问题讨论】:

  • 我没有使用 Esri 的经验,但目前正在学习 Leaflet 和地图。搜索并看到了这种格式。 "geometry" : {"x" : -118.15, "y" : 33.80},如果你这样做,它会起作用吗?如果您创建一个新的 Point() 并设置类型、纬度、经度值或要设置的值怎么办?
  • 感谢您的回复。我使用 new Point() 来声明点。

标签: angular typescript api gis arcgis


【解决方案1】:

而不是使用 变量点={} 我用了 var point=new Point({});

代码会是这样的,

import Point from '@arcgis/core/geometry/Point';

...

var point=new Point({
      longitude:-117.173138,
      latitude: 34.049599
    });

...

【讨论】:

    猜你喜欢
    • 2019-09-09
    • 2019-02-27
    • 1970-01-01
    • 1970-01-01
    • 2019-08-03
    • 2020-10-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多