MovingMarker.zt.js 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. L.Marker.MovingMarker.zt = L.Marker.MovingMarker.extend({
  2. initialize: function (latlngs, durations, options) {
  3. L.AngleMarker.prototype.initialize.call(this, latlngs[0], options);
  4. this._latlngs = latlngs.map(function (e, index) {
  5. return L.latLng(e);
  6. });
  7. if (durations instanceof Array) {
  8. this._durations = durations;
  9. } else {
  10. this._durations = this._createDurations(this._latlngs, durations);
  11. }
  12. this._currentDuration = 0;
  13. this._currentIndex = 0;
  14. this._state = L.Marker.MovingMarker.notStartedState;
  15. this._startTime = 0;
  16. this._startTimeStamp = 0; // timestamp given by requestAnimFrame
  17. this._pauseStartTime = 0;
  18. this._animId = 0;
  19. this._animRequested = false;
  20. this._currentLine = [];
  21. this._stations = {};
  22. this._gjLayer = L.layerGroup().addTo(window.map);
  23. this.circleLayer = []
  24. this.isFollow = false
  25. },
  26. _loadLine: function (index) {
  27. this._currentIndex = index;
  28. this._currentDuration = this._durations[index];
  29. this._currentLine = this._latlngs.slice(index, index + 2);
  30. // this.setIcon(new L.AngleIcon({
  31. // course: this.options.courses[index + 1],
  32. // speed: this.options.speeds[index + 1],
  33. // iconUrl: this.options.iconUrl
  34. // , label: this.options.title
  35. // , showTitle: this.options.showTitle
  36. // , labelPosition: this.options.labelPosition
  37. // }));
  38. //处理过虚拟位置不打点
  39. // if (!(index in this.options.noRealtimeGjList)) {
  40. // var title = formatDate(this.options.collectimes[index] * 1000);
  41. // var circlePoint = L.circleMarker(this._latlngs[index], { zIndexOffset: 10, title: title, radius: 3, color: 'blue' }).addTo(this._gjLayer);
  42. // this.circleLayer.push(circlePoint)
  43. // circlePoint.attributes = this.options.gjData[index];
  44. // circlePoint.bindPopup(this.options.markerPopup(circlePoint.attributes), { autoPan: false, closeButton: false, offset: L.point(130, 255) }); //autoPanPaddingBottomRight ,,{autoPan:false,closeButton:false,offset:L.point(120,185)}
  45. // // var url = _this._jsonUrl+"?format=json&layer="+_this.options.gjLayer+"&customsQuery="+encodeURIComponent("{\"must\":[{\"term\":{\"attributes._targetID\":\""+attr.attributes._targetID+"\"}},{\"range\":{\"attributes.collectime\":{\"lte\":"+endTime+",\"gt\":"+startTime+"}}}]}")+"&sort=collectime:asc";
  46. // let _this = this;
  47. // circlePoint.on('mouseover', function (ev) {
  48. // if (_this.options.pupopOpenHander) {
  49. // clearTimeout(_this.options.pupopOpenHander);
  50. // }
  51. // _this.options.pupopOpenHander = setTimeout(function () {
  52. // ev.target.openPopup();
  53. // }, 500);
  54. // if (_this.options.markerDrawJ) {
  55. // _this.options.layerGroup.removeLayer(_this.options.markerDrawJ)
  56. // }
  57. // _this.options.markerDrawJ = L.marker(ev.target.getLatLng(), { icon: new L.AngleIcon({ iconSize: new L.Point(32, 32) }) }).addTo(_this.options.layerGroup);
  58. // _this.options.markerDrawJ.options.icon.drawJ();
  59. // });
  60. // if (this.options.gjTimeMarker && this.options.layerGroup) {
  61. // if (this.options.gjTimeMarker[index]) {
  62. // this.options.gjTimeMarker[index].addTo(this.options.layerGroup);
  63. // }
  64. // }
  65. // }
  66. //console.log(this._latlngs);
  67. //console.log(this._currentLine);
  68. //console.log(index);
  69. // console.log(this.options.courses[index+1]);
  70. }
  71. });
  72. L.Marker.movingMarker.zt = function (latlngs, duration, options) {
  73. return new L.Marker.MovingMarker.zt(latlngs, duration, options);
  74. };