AnsweredAssumed Answered

Using streamlayer with data coming from a PubNub websocket

Question asked by msilva on Apr 29, 2017
Latest reply on May 1, 2017 by msilva

Hi, I'm trying to use streamlayer accessing ESRI JSON point objects sent as messages to a PubNub channel. I initialized the websocket using:


<!-- Use WebSocket Constructor for a New Socket Connection -->
WebSocket =;
var socket = new WebSocket('wss://');


And used the piece of code bellow but the point is not displaying. I can see that the point object is getting in, the map extent is being updated based on its coordinates, but the symbol is not showing.


Can anybody tell me what I'm doing wrong? Any help will be much appreciated.






PS. Sorry about the code bellow. Could not paste it keeping the formatting I have in my notepad ++.


var symbol = new SimpleMarkerSymbol({
  "color": [255,255,255,64],
  "size": 12,
  "angle": -30,
  "xoffset": 0,
  "yoffset": 0,
  "type": "esriSMS",
  "style": "esriSMSCircle",
  "outline": {
    "color": [0,0,0,255],
    "width": 1,
    "type": "esriSLS",
    "style": "esriSLSSolid"

var svcUrl = "wss://"

var streamLayer = new StreamLayer(featureCollection, {
  socketUrl: svcUrl,
  purgeOptions: { displayCount: 1000, age:20 },
  trackIdField: featureCollection.layerDefinition.timeInfo.trackIdField,
  infoTemplate: new InfoTemplate("${*}" )

//Register listeners for layer events
streamLayer.on("connect", function() {
  console.log("Stream on connect data received.");
  var gra = new Graphic([0], symbol);//[0].geometry, );

//add layer to the map


The data being sent to the websocket is: