The behavior of the point depends on where I was in the opinion of google at a certain point in time.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <div id="map"></div> <!-- --> </body> </html>
!function(){ L.BlackHoleLayer = L.Class.extend({ // initialize: function () { }, // onAdd: function (map) { // , if (this._el) { this._el.style('display', null); // if (this._bh.IsPaused()) this._bh.resume(); return; } this._map = map; // div, // this._el = d3.select(map.getPanes().overlayPane).append('div'); // blackHole this._bh = d3.blackHole(this._el); // div var animated = map.options.zoomAnimation && L.Browser.any3d; this._el.classed('leaflet-zoom-' + (animated ? 'animated' : 'hide'), true); this._el.classed('leaflet-blackhole-layer', true); // map.on('viewreset', this._reset, this) .on('resize', this._resize, this) .on('move', this._reset, this) .on('moveend', this._reset, this) ; this._reset(); }, // leaflet onRemove: function (map) { // . this._el.style('display', 'none'); // , if (this._bh.IsRun()) this._bh.pause(); }, // . addTo: function (map) { map.addLayer(this); return this; }, // resize _resize : function() { // . this._bh.size([this._map._size.x, this._map._size.y]); this._reset(); }, // _reset: function () { var topLeft = this._map.containerPointToLayerPoint([0, 0]); var arr = [-topLeft.x, -topLeft.y]; var t3d = 'translate3d(' + topLeft.x + 'px, ' + topLeft.y + 'px, 0px)'; this._bh.style({ "-webkit-transform" : t3d, "-moz-transform" : t3d, "-ms-transform" : t3d, "-o-transform" : t3d, "transform" : t3d }); this._bh.translate(arr); } }); L.blackHoleLayer = function() { return new L.BlackHoleLayer(); }; }();
// div#map var map = new L.Map('map', { maxZoom : 19, // minZoom : 2 // }).setView([0,0], 2); // // google c ROADMAP . var ggl = new L.Google('ROADMAP', { mapOptions: { backgroundColor: "#19263E", styles : [ { "featureType": "water", "stylers": [ { "color": "#19263E" } ] }, { "featureType": "landscape", "stylers": [ { "color": "#0E141D" } ] }, { "featureType": "poi", "elementType": "geometry", "stylers": [ { "color": "#0E141D" } ] }, { "featureType": "road.highway", "elementType": "geometry.fill", "stylers": [ { "color": "#21193E" } ] }, { "featureType": "road.highway", "elementType": "geometry.stroke", "stylers": [ { "color": "#21193E" }, { "weight": 0.5 } ] }, { "featureType": "road.arterial", "elementType": "geometry.fill", "stylers": [ { "color": "#21193E" } ] }, { "featureType": "road.arterial", "elementType": "geometry.stroke", "stylers": [ { "color": "#21193E" }, { "weight": 0.5 } ] }, { "featureType": "road.local", "elementType": "geometry", "stylers": [ { "color": "#21193E" } ] }, { "elementType": "labels.text.fill", "stylers": [ { "color": "#365387" } ] }, { "elementType": "labels.text.stroke", "stylers": [ { "color": "#fff" }, { "lightness": 13 } ] }, { "featureType": "transit", "stylers": [ { "color": "#365387" } ] }, { "featureType": "administrative", "elementType": "geometry.fill", "stylers": [ { "color": "#000000" } ] }, { "featureType": "administrative", "elementType": "geometry.stroke", "stylers": [ { "color": "#19263E" }, { "lightness": 0 }, { "weight": 1.5 } ] } ] } }); // . map.addLayer(ggl);
// blackHole.js var visLayer = L.blackHoleLayer() , heat = L.heatLayer( [], { // heatmap opacity: 1, // radius: 25, // blur: 15 // }).addTo( map ) // heatmap ; visLayer.addTo(map); // blackHole.js
var rawData = [ { "key": 237, "category": "nemo,", "parent": { "name": "cumque5", "key": 5 }, "date": "2014-01-30T12:25:14.810Z" }, //... ]
var data = rawData.map(function(d) { d.date = new Date(d.date); return d; }) , stepDate = 864e5 , d3bh = d3.blackHole("#canvas") ; d3bh.setting.drawTrack = true; d3bh.on('calcRightBound', function(l) { return +l + stepDate; }) .start(data) ;
{ "somePointsTruncated" : false, "locations" : [ { "timestampMs" : "1412560102986", "latitudeE7" : 560532385, "longitudeE7" : 929207681, "accuracy" : 10, "velocity" : -1, "heading" : -1, "altitude" : 194, "verticalAccuracy" : 1 }, { "timestampMs" : "1412532992732", "latitudeE7" : 560513299, "longitudeE7" : 929186602, "accuracy" : 10, "velocity" : -1, "heading" : -1, "altitude" : 203, "verticalAccuracy" : 2 }, //... ]}
function restart() { bh.stop(); if ( !locations || !locations.length) return; // heatmap heat.setLatLngs([]); // bh.start(locations, map._size.x, map._size.y, true); visLayer._resize(); }
var parentHash; // . function stageTwo ( file ) { bh.stop(); // // LocationHistory leaflet.js var SCALAR_E7 = 0.0000001; // processFile( file ); function processFile ( file ) { // FileReader var reader = new FileReader(); reader.onprogress = function ( e ) { // }; reader.onload = function ( e ) { try { locations = JSON.parse( e.target.result ).locations; if ( !locations || !locations.length ) { throw new ReferenceError( 'No location data found.' ); } } catch ( ex ) { // console.log(ex); return; } parentHash = {}; // var sw = [-Infinity, -Infinity] , se = [Infinity, Infinity]; locations.forEach(function(d, i) { d.timestampMs = +d.timestampMs; // // d.lat = d.latitudeE7 * SCALAR_E7; d.lon = d.longitudeE7 * SCALAR_E7; // parent d.pkey = d.latitudeE7 + "_" + d.longitudeE7; // sw[0] = Math.max(d.lat, sw[0]); sw[1] = Math.max(d.lon, sw[1]); se[0] = Math.min(d.lat, se[0]); se[1] = Math.min(d.lon, se[1]); // , . d.parent = parentHash[d.pkey] || makeParent(d); }); // locations.sort(function(a, b) { return a.timestampMs - b.timestampMs; }); // id locations.forEach(function(d, i) { d._id = i; }); // map.fitBounds([sw, se]); // restart(); }; reader.onerror = function () { console.log(reader.error); }; // reader.readAsText(file); } } function makeParent(d) { var that = {_id : d.pkey}; // leaflet that.latlng = new L.LatLng(d.lat, d.lon); // // that.x = { valueOf : function() { var pos = map.latLngToLayerPoint(that.latlng); return pos.x; } }; that.y = { valueOf : function() { var pos = map.latLngToLayerPoint(that.latlng); return pos.y; } }; return parentHash[that.id] = that; }
// bh.setting.increaseChild = false; bh.setting.createNearParent = false; bh.setting.speed = 100; // bh.setting.zoomAndDrag = false; bh.setting.drawParent = false; // parent bh.setting.drawParentLabel = false; // bh.setting.padding = 0; // bh.setting.parentLife = 0; // bh.setting.blendingLighter = true; // Canvas bh.setting.drawAsPlasma = true; // bh.setting.drawTrack = true; // var stepDate = 1; // // , , (d) bh.on('getGroupBy', function (d) { // return d._id //d.timestampMs; }) .on('getParentKey', function (d) { return d._id; // }) .on('getChildKey', function (d) { return 'me'; // , }) .on('getCategoryKey', function (d) { return 'me; // , }) .on('getCategoryName', function (d) { return 'location'; // }) .on('getParentLabel', function (d) { return ''; // }) .on('getChildLabel', function (d) { return 'me'; // }) .on('calcRightBound', function (l) { // . return l + stepDate; }) .on('getVisibleByStep', function (d) { return true; // }) .on('getParentRadius', function (d) { return 1; // }) .on('getChildRadius', function (d) { return 10; // }) .on('getParentPosition', function (d) { return [dx, dy]; // }) .on('getParentFixed', function (d) { return true; // }) .on('processing', function(items, l, r) { // heatmap setTimeout(setMarkers(items), 10); }) .sort(null) ; // heatmap function setMarkers(arr) { return function() { arr.forEach(function (d) { var tp = d.parentNode.nodeValue; // heatmap heat.addLatLng(tp.latlng); }); } }
Source: https://habr.com/ru/post/241023/
All Articles