TransWikia.com

How to implement search in a graphics layer?

Geographic Information Systems Asked on April 10, 2021

There is a method that accepts JSON data. Based on this data, points are created and added to the graphics layer. How to implement search in a graphics layer? I found an example of how to implement search in FeatureLayer (sample)! How to do the same in GraphicsLayer?

A method that draws the JSON points:

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);
                }
            }

One Answer

From the search documentation:
"The Search widget provides a way to perform search operations on locator service(s) and/or map/feature service feature layer(s)"
"Feature layers created from client-side graphics are not supported."
Based on the doc, it seems that the Search widget can't be used for graphics layers.

Answered by NettaB on April 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP