1// TrackLayer.js 2// Copyright 2012 Artem Prilutskiy 3 4var TrackFormat = OpenLayers.Class(OpenLayers.Format.JSON, 5 { 6 read: function(data, filter) 7 { 8 var points = []; 9 var features = []; 10 for (var key in data) 11 { 12 var position = data[key]; 13 if ((position['position'] != undefined) && 14 (position['key'] != undefined)) 15 { 16 var point = new OpenLayers.Geometry.Point(position['position'][0], position['position'][1]); 17 features.push(new OpenLayers.Feature.Vector(point, { name: position['key'] })); 18 points.push(point.clone()); 19 } 20 } 21 var line = new OpenLayers.Geometry.LineString(points) 22 features.push(new OpenLayers.Feature.Vector(line)); 23 return features; 24 } 25 } 26); 27 28function createTrackLayer(name, call, interval, color) 29{ 30 var style = new OpenLayers.Style( 31 { 32 strokeColor: color, 33 strokeOpacity: 0.6, 34 strokeWidth: 1.4, 35 fillColor: color, 36 fillOpacity: 0.6, 37 pointRadius: 3, 38 pointerEvents: 'visiblePainted' 39 } 40 ); 41 42 var strategy = new OpenLayers.Strategy.Refresh( 43 { 44 interval: 30000 45 } 46 ); 47 48 var layer = new OpenLayers.Layer.Vector( 49 name, 50 { 51 projection: new OpenLayers.Projection('EPSG:4326'), 52 strategies: 53 [ 54 new OpenLayers.Strategy.Fixed(), 55 strategy 56 ], 57 protocol: new OpenLayers.Protocol.Script( 58 { 59 url: 'https://tracker.dstar.su/api/track.php', 60 params: { call: call, interval: interval }, 61 callbackKey: 'callback', 62 format: new TrackFormat() 63 } 64 ), 65 styleMap: new OpenLayers.StyleMap({ default: style }) 66 } 67 ); 68 69 if (typeof tryRegisterPushUpdates == 'function') 70 tryRegisterPushUpdates(strategy, 'APRS/' + call, 'updatePosition'); 71 72 return layer; 73};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.