向要素图层添加多点

时间:2018-07-31 10:42:54

标签: dictionary websocket multipoint

我想在收到网络套接字消息时显示一个标记,但与此同时

代码我只能显示第一个点,然后当我收到第二个消息时就不能显示它。

此代码是否有问题?

socket.onmessage = function(e) {

                        var message = e.data;
                        alert("Message is received...");
                        console.log(message);
featureCollection.layerDefinition.drawingInfo.renderer.symbol.angle = course;

featureCollection.layerDefinition.drawingInfo.renderer.symbol.url = alpha;

                        featureLayer = new FeatureLayer(featureCollection, {
                            id: 'Tracking',
                            infoTemplate: popupTemplate
                        });

                        //associate the features with the popup on click
                        featureLayer.on("click", function(evt) {
                            map.infoWindow.setFeatures([evt.graphic]);
                        });

                        var location = {
                            latitude: lat,
                            longitude: Lon

                        };
                        point = new Point({
                            longitude: 0,
                            latitude: 0
                        });

                        point.longitude = location.longitude;
                        point.latitude =location.latitude;

                        console.log(point);
                        graphic = new Graphic({
                            geometry: point
                        });
                        var contentString = '<div id="content">'+
                                '<div id="siteNotice">'+
                                '</div>'+
                                '<h1 id="firstHeading" class="firstHeading"> Info </h1>'+
                                '<div id="bodyContent">'+
                                '<p><b> Date : </b> ' + times+
                                '<p><b> Vitesse : </b> ' + speed + ' <b> km/h </b> ' +
                                '<p><b> Distance : </b> ' + distance + ' <b> m </b> ' +
                                '<p><b> Altitude : </b> ' + alt + ' <b> m </b> ' +
                                '<p><b> Direction : </b> ' + course+ ' <b> ° </b> ' +
                                '<p><b> Status : </b> ' + infostatus +
                                '</div>'+
                                '</div>';

                        attr["description"] = contentString  ;
                        attr["title"] = "Device :0906050400030201";

                        graphic.setAttributes(attr);

                        features.push(graphic);
                        console.log(features);
                            map.addLayers([featureLayer]);
                };
                map.on("layers-add-result", function(results) {
                    console.log(location)
                    featureLayer.applyEdits(features,features,null);

                });

如何修复它以显示多点?

0 个答案:

没有答案