可以制作复合符号吗?

时间:2016-08-26 22:05:13

标签: symbols esri arcgis-js-api

编辑顶点时,我想用SimpleMarkerSymbol和TextSymbol替换顶点符号,但这似乎是不可能的。有关如何做到这一点的任何建议?我希望拖动这样的东西(文字+圆圈):

enter image description here

花了一些时间来查看API我得出的结论是不可能的。这是我的解决方法:

editor.on("vertex-move", args => {
    let map = this.options.map;
    let g = <Graphic>args.vertexinfo.graphic;
    let startPoint = <Point>g.geometry;
    let tx = args.transform;
    let endPoint = map.toMap(map.toScreen(startPoint).offset(tx.dx, tx.dy));

    // draw a 'cursor' as a hack to render text over the active vertex
    if (!cursor) {
        cursor = new Graphic(endPoint, new TextSymbol({text: "foo"}));
        this.layer.add(cursor);
    } else {
        cursor.setGeometry(endPoint);
        cursor.draw();
    }
})

2 个答案:

答案 0 :(得分:0)

嗯,到目前为止,实现这似乎不可能但是ArcGIS JS API提供了一个新的应用程序/平台,您可以在其中为您的应用程序在线生成单个符号。

我们可以在线创建所有类型的符号(由ESRI提供),它可以为您提供您需要粘贴到应用程序中的快速代码。

这将有助于我们为应用程序尝试不同类型的合适符号。

应用程序网址:https://developers.arcgis.com/javascript/3/samples/playground/index.html

希望这会对你有所帮助:)。

答案 1 :(得分:0)

您可以使用TextSymbol创建一个字体类型在圆圈内具有数字的点。这是一个你可以找到这种字体的地方。 http://www.fontspace.com/the-fontsite/combinumerals

不完全如图所示,但足够接近。还有一些限制它不适用于IE9或更低(这是根据esri文档,因为我使用光环来获得白色边框)。

以下是工作Jsbin:http://jsbin.com/hayirebiga/edit?html,output多点使用点

PS:我已将ttf转换为otf,然后将字体添加为base64,这是可选的。我做到了,因为我无法将ttf或otf添加到jsbin。