| var realtime = L.realtime({ | |
| url: 'http://chase.feastspider.com/data/fs.json', | |
| crossOrigin: true, | |
| type: 'json' | |
| }, { | |
| interval: 1 * 15000, | |
| pointToLayer: function (feature, latlng) { | |
| return L.marker(latlng, { | |
| 'icon': L.icon({ | |
| iconUrl: 'camera.png', | |
| iconSize: [24, 24], // size of the icon | |
| iconAnchor: [12,12], // point of the icon which will correspond to marker's location | |
| popupAnchor: [0, 0] // point from which the popup should open relative to the iconAnchor | |
| }) | |
| }); | |
| } | |
| }).addTo(map); | |
| realtime.on('update', function(e) { | |
| popupContent = function(fId) { | |
| var feature = e.features[fId], | |
| c = feature.geometry.coordinates; | |
| return feature.properties.upper + '<img src="http://chase.feastspider.com/static/test.flv.png" style=\"width:275px\"><br><i class=\"fa fa-video-camera\"> View Stream</i>'}, | |
| bindFeaturePopup = function(fId) { | |
| realtime.getLayer(fId).bindPopup(popupContent(fId)); | |
| }, | |
| updateFeaturePopup = function(fId) { | |
| realtime.getLayer(fId).getPopup().setContent(popupContent(fId)); | |
| }; | |
| Object.keys(e.enter).forEach(bindFeaturePopup); | |
| Object.keys(e.update).forEach(updateFeaturePopup); | |
| }); | |
| realtime.on('mouseover', function(e) { | |
| e.layer.openPopup(); | |
| }); |