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 = PUBNUB.ws;
var socket = new WebSocket('wss://pubsub.pubnub.com/my-publish-key/my-subscribe-key/my-channel');
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.
Thanks,
Marcus
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://pubsub.pubnub.com/my-publish-key/my-subscribe-key/my-channel"
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.");
console.log(message.data[0]);
map.setExtent(map.extent.centerAt(webMercatorUtils.geographicToWebMercator(jsonUtils.fromJson(message.data[0].geometry))));
var gra = new Graphic(message.data[0], symbol);//[0].geometry, );
streamLayer.add(gra);
});
//add layer to the map
map.addLayer(streamLayer);
============================================================================
The data being sent to the websocket is:
[{"geometry":{"type":"point","x":-77.506431000,"y":39.466250000,"z":87.3,"spatialReference":{"wkid":102100}},"attributes":{"trackId":1,"time":"2011-09-25T18:08:35Z"}}]