hallahan / LeafletPlayback

This is a Leaflet plug-in that plays back points that have a time stamp synchronized to a clock.
http://leafletplayback.theoutpost.io
Other
483 stars 167 forks source link

Draw line on leaflet playback map instead of circle #44

Closed Radhakrishanan closed 8 years ago

Radhakrishanan commented 8 years ago

I need to draw line on leaflet playback map instead of circle, i try following code but didn't work well.

L.Playback = L.Playback || {};

L.Playback.TracksLayer = L.Class.extend({ initialize: function (map, options) { var layer_options = options.layer || {};

    if (jQuery.isFunction(layer_options)) {
        layer_options = layer_options(feature);
    }

    if (!layer_options.pointToLayer) {
        layer_options.pointToLayer = function (featureData, latlng) {
            //return new L.polyline(latlng, { radius: 5 });

            **return new L.polyline(latlng, {
                color: 'red',
                weight: 3,
                opacity: 0.5,
                smoothFactor: 1

            });
        };**
    }

    this.layer = new L.GeoJSON(null, layer_options);

    var overlayControl = {
        'GPS Tracks': this.layer
    };

    L.control.layers(null, overlayControl, {
        collapsed: false
    }).addTo(map);
},

// clear all geoJSON layers
clearLayer: function () {
    for (var i in this.layer._layers) {
        this.layer.removeLayer(this.layer._layers[i]);
    }
},

// add new geoJSON layer
addLayer: function (geoJSON) {
    this.layer.addData(geoJSON);
}

}); My Json coords are below,

var tillicum=[{'type': 'Feature','geometry': {'type': 'MultiPolygon','coordinates': [ [ 79.825108,11.958093 ],[ 79.826233,11.957887 ],[ 79.826267,11.957808 ], ] }, 'properties': { 'title': 'tillicum', 'path_options': { 'color': 'red' }, 'time':[ 1468905535000,1468905595000,1468905597000,],'speed':[13.5023626],'altitude':[158.33] },}]

hallahan commented 8 years ago

This is simply not a feature in the library. However, you can easily do this yourself. Add a polyline GeoJSON layer yourself. Then, don't turn on the points in LeafletPlayback.

Radhakrishanan commented 8 years ago

Hi hallahan, I got what was am expecting i use "type": "LineString" instead of "type": "MultiPoint",

Now i would like to ask one i.e, in our marker popup show geojson latlan but i want to show speed on it, how i can do ?

Thank you so much ,