有一个接受JSON数据的方法。基于此数据,将创建点并将其添加到图形层。如何在图形层中实现搜索?我找到了一个如何在FeatureLayer(sample)中实现搜索的示例!如何在GraphicsLayer中做同样的事情?
一种绘制点的方法:
function draw_point_layer(stations, list_name_net) {
console.log(stations);
for (i = 0; i < stations.length; i++) {
var point = {
type: "point", // autocasts as new Point()
longitude: stations[i]['longitude'],
latitude: stations[i]['latitude']
};
var pointAtt = {
Code: stations[i]['sitecode'],
Name: "<a href='" + stations[i]['link'] + "'>" + stations[i]['name'] + "</a>",
Type: stations[i]['type'],
Nets: list_name_net[i]
};
var pointGraphic = new Graphic({
geometry: point,
symbol: markerSymbol,
attributes: pointAtt,
popupTemplate: {
content: [{
type: "fields",
fieldInfos: [
{
fieldName: "Code",
label: 'Код',
},
{
fieldName: "Name",
label: 'Имя',
},
{
fieldName: "Type",
label: 'Тип',
},
{
fieldName: "Nets",
label: 'Сети',
},
]
}]
}
});
pointLayer.add(pointGraphic);
}
}