Code Monkey home page Code Monkey logo

leaflet-realtime's Introduction

Leaflet Realtime

Build status NPM version Leaflet 1.0 compatible! CDNJS Greenkeeper badge

Put realtime data on a Leaflet map: live tracking GPS units, sensor data or just about anything.

Note: version 2 and up of this plugin is _only compatible with Leaflet 1.0 and later. Use earlier versions of Leaflet Realtime if you need Leaflet 0.7 compatibility.

Example

Checkout the Leaflet Realtime Demo. Basic example:

var map = L.map('map'),
    realtime = L.realtime({
        url: 'https://wanderdrone.appspot.com/',
        crossOrigin: true,
        type: 'json'
    }, {
        interval: 3 * 1000
    }).addTo(map);

realtime.on('update', function() {
    map.fitBounds(realtime.getBounds(), {maxZoom: 3});
});

Usage

Overview

By default, Leaflet Realtime reads and displays GeoJSON from a provided source. A "source" is usually a URL, and data can be fetched using AJAX (XHR), JSONP. This means Leaflet Realtime will poll for data, pulling it from the source. Alternatively, you can write your own source, to provide data in just about any way you want. Leaflet Realtime can also be made work with push data, for example data pushed from the server using socket.io or similar.

To be able to figure out when new features are added, when old features are removed, and which features are just updated, Leaflet Realtime needs to identify each feature uniquely. This is done using a feature id. Usually, this can be done using one of the feature's properties. By default, Leaflet Realtime will try to look for a called property id and use that.

By default, L.Realtime uses a L.GeoJSON layer to display the results. You can basically do anything you can do with L.GeoJSON with L.Realtime - styling, onEachFeature, gettings bounds, etc. as if you were working directly with a normal GeoJSON layer.

L.Realtime can also use other layer types to display the results, for example it can use a MarkerClusterGroup from Leaflet MarkerCluster: pass a LayerGroup (or any class that implements addLayer and removeLayer) to L.Realtime's container option. (This feature was added in version 2.1.0.)

Typical usage involves instantiating L.Realtime with options for style and/or onEachFeature, to customize styling and interaction, as well as adding a listener for the update event, to for example list the features currently visible in the map.

Since version 2.0, Leaflet Realtime uses the Fetch API to request data (AJAX). If you are in the unfortunate situation that you need to support a browser without Fetch, you either need to use a polyfill, or write your own source function to make the AJAX requests.

Push data

If you prefer getting data pushed from the server, in contrast to Leaflet Realtime pulling it with a standard HTTP request, you can feed added and updated GeoJSON data to Leaflet Realtime using the update method. In this scenario, you will also need to remove features by explicit calls to remove.

Since automatic updates do not make sense in a push scenario, you want to create the layer with the option start set to false.

API

L.Realtime

This is a realtime updated layer that can be added to the map. It extends L.GeoJSON.

Creation
Factory Description
L.Realtime(<Source> source, <RealtimeOptions> options?) Instantiates a new realtime layer with the provided source and options
Options

Provides these options, in addition to the options of L.GeoJSON.

Option Type Default Description
start Boolean true Should automatic updates be enabled when layer is added on the map and stopped when layer is removed from the map
interval Number 60000 Automatic update interval, in milliseconds
getFeatureId(<GeoJSON> featureData) Function Returns featureData.properties.id Function used to get an identifier uniquely identify a feature over time
updateFeature(<GeoJSON> featureData, <ILayer> oldLayer) Function Special Used to update an existing feature's layer; by default, points (markers) are updated, other layers are discarded and replaced with a new, updated layer. Allows to create more complex transitions, for example, when a feature is updated
container LayerGroup L.geoJson() Specifies the layer instance to display the results in
removeMissing Boolean false Should missing features between updates been automatically removed from the layer
Events
Event Data Description
update UpdateEvent Fires when the layer's data is updated
Methods
Method Returns Description
start() this Starts automatic updates
stop() this Stops automatic updates
isRunning() Boolean Tells if automatic updates are running
update(<GeoJSON> featureData?) this Updates the layer's data. If featureData is provided, it is used to add or update data in the layer, otherwise the layer's source is queried for new data asynchronously
remove(<GeoJSON> featureData) this Removes the provided feature or features from the layer
getLayer(<FeatureId> featureId) ILayer Retrieves the layer used for a certain feature
getFeature(<FeatureId> featureId) GeoJSON Retrieves the feature data for the given featureId

Source

The source can be one of:

  • a string with the URL to get data from
  • an options object that is passed to fetch for fetching the data
  • a function in case you need more freedom.

In case you use a function, the function should take two callbacks as arguments: fn(success, error), with the callbacks:

  • a success callback that takes GeoJSON as argument: success(<GeoJSON> features)
  • an error callback that should take an error object and an error message (string) as argument: error(<Object> error, <String> message)

UpdateEvent

An update event is fired when the layer's data is updated from its source. The data included loosely resembles D3's join semantics, to make it easy to handle new features (the enter set), updated features (the update set) and removed features (the exit set).

property type description
features Object Complete hash of current features, with feature id as key
enter Object Features added by this update, with feature id as key
update Object Existing features updated by this update, with feature id as key
exit Object Existing features that were removed by this update, with feature id as key

leaflet-realtime's People

Contributors

claustres avatar greenkeeper[bot] avatar greenkeeperio-bot avatar guiled avatar johschmitz avatar jtm240 avatar kennynaoh avatar lnkpaulo avatar pabloroz avatar perliedman avatar waldyrious avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leaflet-realtime's Issues

Leaflet realtime changing marker color

Hello,

I'm using leaflet realtime library (https://github.com/perliedman/leaflet-realtime), I' am also using a counter in my code that I need the L.CircleMarker color changes if yCont variable is odd or not, according each case it evaluates correctly the conditions but the L.CircleMarker color is not changing, when it's changing the position of the L.CircleMarker. Is it possible to do that with this library?, This is my code:

realtime = L.realtime({
url: 'https://wanderdrone.appspot.com/',
crossOrigin: true,
type: 'json'
}, {
interval: 3 * 1000,
pointToLayer: function (feature, latlng) {
if(yCont%2==0){
return new L.CircleMarker(latlng, {
radius: 5,
fillColor: "#00FF00",
color: "#000",
weight: 1,
opacity: 1,
fillOpacity: 1.0
});
}
if(yCont%2==1){
return new L.CircleMarker(latlng, {
radius: 5,
fillColor: "#FF0000",
color: "#000",
weight: 1,
opacity: 1,
fillOpacity: 1.0
});
}

   }

}).addTo(map);

realtime.on('update', function(e) {
yCont=yCont+1;
map.fitBounds(realtime.getBounds(), {maxZoom: 3});
});
Thanks in advance.

How to add start - stop update control

At first place, thank you for the great code, Sir!

I would like add start stop controls to the update. Can you show me an example of what is the best approach to do this.

Thank you in advance!

live tracking GPS units

Hello leaflet-realtime team,

I would like to track GPS units using leaflet-realtime.

I have no idea how to push GPS location details to leaflet-realtime.

May I know the details of how to integrate GPS from mobile to leaflet-realtime ?

I thought of using https://www.traccar.org/.

Please educate me on this issue.

Thanks.

Zoom snaps back on update

Would be nice to have this not happen, so when a gps tracker is moving and the user has zoomed in or out, the map doesn't snap back out or in to its default zoom level. Quite distracting.

User needs to zoom in and follow at closer level of detail.

Currently any zoom by the user is undone when the update hits.

How to make it work with linestrings

Hi, perliedman!

Thank you for writing this code out! It worked with points, and maybe worked with polygons as well (didn't have real changing data to test this out, but at least the website is functioning and didn't break). However, when I wanted to auto-update some lines (from a separate geojson), the website broke. The geojson is "not well formed" according to Inspect Element -->Console, and that's how I know the website is updating (with the points and the polygons). Do you have any clues?

Thanks,
Gloria

Local gps input without using geoJSON

Hi perliedman

In the examples folder of leaflet-realtime, the file "index.js" starts out as:

var map = L.map('map'),
    realtime = L.realtime({
        url: 'https://wanderdrone.appspot.com/',
        crossOrigin: true,
        type: 'json'
    }, {
        interval: 3 * 1000
    }).addTo(map);

How do we use local data where gps is already stored as php variables? Currently the example points to Wanderdrone, but doesn't explain how the geoJSON string is built on the sending side.

I have php variables for lat and lon stored on my server, and all I need is to pass them to L.realtime. I am not good with js, so could use a bit of help. Perhaps you could add another function
to handle local php variables akin to...

var map = L.map('map'),
    realtime = L.realtime({
        url: 'localhost/gps.php',
        type: 'php'
    }, {
        interval: 3 * 1000
    }).addTo(map);

Where gps.php retrieves the values of $lat and $lon.

or could you provide an example how to build a simple php page to serve a geoJSON string, similar to the output from Wanderdrone.

{"geometry": {"type": "Point", "coordinates": [92.838612769265353, 11.693297684792899]}, "type": "Feature", "properties": {}}

Regards

Lee

How to use push model in leaflet realtime js api

On leaflet-realtime website the example is for pull model for realtime tracking of gps. There is an instruction that it can be used with push model. Is there any example for push model? Lets say I am getting stream of gps coordinates and I want to push them to leaflet realtime.

Push Example

firstly thanks a ton for the wonderful plugin. It has been really useful. But how would I get this to work with push? I mean when my MySQL database gets updated with data from a gps tracker, how can I push this to refresh and update the display? I am a little clueless as to how / where to implement the push. If you could give me some pointers it would be great.

Thanks once again for the great work,
M&M

Memory explosion

My data contains ~4000 - ~5000 LineString, Memory balloons until browsers crash.

I have some profiling information (timeline and two heapsnapshot) from chrome (Version 55.0.2883.95 (64-bit)) on osx. Same experience with Safari and Firefox, but the three files are 165MB compressed and I'm unable to upload.

after ~1hr of updates the browser is consuming ~10GB memory.

updates interval is 30 seconds.

I'll work on sanitizing the sources and include tomorrow.

Instructions to Run

Hi ,
I have downloaded the respository as a zip.
How do you run it ? I just opened index.html

Can you please share the instruction to run it

Thanks

How to get styling to work?

I have LineString data with a style and highlight.
If I load this into a GeoJSON layer it works fine.
If I load it with realtime layer all lines are blue until I hover (use the highlight mouseover mouseout) which calls setStyle.
How can I update the styles with new data is loaded?
I've tried the updateFeature option as suggested in the update markers issue.

image

Update realtime by updating its geojson feature

Hello there,

I'm pretty new to leaflet realtime, but I already know that it will be a great great component for my projects! Thank you for development and support!

I still do have a question. I'm working with a single geojson feature looking like that:

var geojsonFeature = {
"type": "Feature",
"properties": {
"name": "marker"
},
"geometry": {
"type": "Point",
"coordinates": [13.53, 52.44]
}
};

I'm initiating the map and leaflet realtime with this:

map = L.mapbox.map('map', 'mapbox.streets', { // 'mapbox.streets'
maxBounds: [[52.3,12.5],[52.8,14.2]]
}), realtime = L.realtime({
geojsonFeature,
crossOrigin: true,
type: 'json'
}, {
interval: 1 * 500
}).addTo(map);

Until here, everything works perfectly fine. There is a marker at the position in question.

The user can modify the position of the marker with this function:

function modify(lng, lat) {
geojsonFeature.geometry.coordinates[0] = lng;
geojsonFeature.geometry.coordinates[1] = lat;
//realtime.update();
}

And here is where I got stuck. My realtime marker is not updating its position. I tried calling realtime.update(), but as far as I read, realtime should regularly update itself by calling its source. The source will be modified by the above method, so the marker should move once the method is called. That is, however, not the case. Is there a step I missed?

I'd be very thankful for your help!

edit: Okay, I got it sorted out, I didn't carefully read the paragraph about defining a success-error-function as first parameter...works like a charm after some back and forth... :)

Busses example

Hi perliedman

Could you post the code for the busses example. Would give a great idea on how multiple moving markers work.

sword

Change marker icon, when update json properties.

Hello, i am sorry but i don't need update my coordinates, i want use it for update my markers icons depend on value of any property.
For example my json is:

{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates":
[87.95235,52.9535]

        },
        "properties": {
            "name": "MK Lift queues",
            "Qtype": "3",
            "id": "101"
        }

    },
    {
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates":
                [87.94178,52.96022]

        },
        "properties": {
            "name": "Dollar Lift Queues",
            "Qtype": "1",
            "id": "102"
        }

    }

]

}

And my part of code index.js is:
var realtime = L.realtime({
url:'queues.geojson',
crossOrigin: true,
type: 'json'},
{interval: 3000,

// onEachFeature: onEachFeature,
pointToLayer: function (feature, latlng) {
if (feature.properties.Qtype == "4"){
return L.marker(latlng, {icon: LiftQ4Icon});
}
if (feature.properties.Qtype == "3"){
return L.marker(latlng, {icon: LiftQ3Icon});
}
if (feature.properties.Qtype == "2"){
return L.marker(latlng, {icon: LiftQ2Icon});
}
if (feature.properties.Qtype == "1"){
return L.marker(latlng, {icon: LiftQ1Icon});
}
}

                            }
                    ).addTo(liftsgroup);

So it updates markers only when i reload the page, but i wand to update markers, when i change property "Qtype". Help me please, and sorry for my bad english.

Realtime reqwest basic auth

hi, is it possible to do basic authentication with an nginx server. I am using the reqwest method as described in the earlier trains example. Thanks

Leaflet Realtime plugIn use with GeoJson

I have a file GeoJSON "plaques.js" and I want you with leaflet realtime plugin (all markers simultaneously) spend. Can you help me?

here the geojson- file:

var plaques={"type":"FeatureCollection","features":[

{"type":"Feature","geometry":{"type":"Point","coordinates":[13.523563700000068,52.4909447]},"properties":{"plaqueid":"1","plaquedesc":"Berlin","colour":"","pc":"master"}},
{"type":"Feature","geometry":{"type":"Point","coordinates":[9.99368179999999,53.5510846]},"properties":{"plaqueid":"2","plaquedesc":"Hamburg","colour":"0","pc":"wn"}},
{"type":"Feature","geometry":{"type":"Point","coordinates":[11.581980599999952,48.1351253]},"properties":{"plaqueid":"3","plaquedesc":"Muenchen","colour":"128","pc":"wn"}},
{"type":"Feature","geometry":{"type":"Point","coordinates":[8.682126700000026,50.1109221]},"properties":{"plaqueid":"4","plaquedesc":"Frankfurt am Main","colour":"-128","pc":"wn"}}
]}

Removing and Re-adding a Marker

I have a collection of Features I'm passing in and would like to remove one of the markers based on a change in its status. The remove function works in taking the marker off the screen, but if new data is received to recreate the marker with the same ID, it doesn't work. It goes through the normal update procedure but won't recreate the icon. After a marker.setIcon(...), the _icon object is always "null".

Am I missing something, or am I not supposed to be able to remove and re-add the same ID without a page refresh?

Publish array of points

Hi, great tool! Thanks. I want to show a map with an array of points (not a multipoint geometry) because I need to show many properties for each point. It's possible? I could't find the way.

Example:
var someFeatures = [{ "type": "Feature", "properties": { "name": "Coors Field" }, "geometry": { "type": "Point", "coordinates": [-105.35721, 40.25846] } }, { "type": "Feature", "properties": { "name": "Busch Field" }, "geometry": { "type": "Point", "coordinates": [-104.98404, 39.74621] } }];

Trail - Pass over the W180 line of longitude.

The exemple "trail.js", when a trail straddles the W180 line of longitude, crossing from one side to the other, the trail does not continue on the other side of the W180 line, but is drawn back on the other side of the "current iteration" of the world.
How to change it?

Thanks,

Remove dependency on reqwest

Bundling with an XHR lib is great for convenience, but also bloats the plugin.

Look into other options, try to make it possible to use Leaflet Realtime with any XHR lib.

Multiple Markers

Is it possible to pull from one server or servers to not just one marker being tracked but a lot more being tracked at the same time?

Only seing the last marker updating

Hi,

Below is a sample data I am using to update in realtime. My problem is that I only see the last marger on my map. My type is the "FeatureCollection" and I do not want to use "multipoint" because I need a setof features for each point. Can someone tell me what I am doing wrong here?

      ...  success({
            type: 'FeatureCollection',
            features: [data]
        });

{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": "1",
"properties": {
"Name": "Worker1",
"Status": "break"
},
"geometry": {
"type": "Point",
"coordinates": [
-112.7171529,
33.4954179
]
}
},
{
"type": "Feature",
"id": "2",
"properties": {
"Name": "Worker2",
"Status": "work"
},
"geometry": {
"type": "Point",
"coordinates": [
-115.7171529,
32.4954179
]
}
}
]
}

How to use push model in leaflet realtime js api

On leaflet-realtime website the example is for pull model for realtime tracking of gps. There is an instruction that it can be used with push model. Is there any example for push model? I want would like to use redis and leaflet realtime together, where data will come from redis.

examples index.html not working

I just tried to run the index.html in examples using Google Chrome on Windows 7 and it is not loading the basemap tiles nor the point marker. trail.html seems to be working just fine though.

An in-range update of browserify is breaking the build 🚨

Version 14.3.0 of browserify just got published.

Branch Build failing 🚨
Dependency browserify
Current Version 14.2.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As browserify is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪


Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details
Commits

The new version differs by 4 commits .

  • cd01926 14.3.0
  • 08caf04 changelog
  • ad5060d Merge pull request #1710 from substack/https-browserify-1
  • 7c7b4d4 update https-browserify to ^1.0.0

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Multiple Markers in geojson

So my issue is that I am trying to load multiple markers from a json file formatted to geojson but only the first marker ever shows up on the map.

Example of file:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "Name": "Worker1",
        "Status": "break"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          -112.7171529,
          33.4954179
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "Name": "Worker2",
        "Status": "work"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          -115.7171529,
          32.4954179
        ]
      }
    }
  ]
}

example of js:

realtime = L.realtime({
          url: 'myaddress/locations.json',
          crossOrigin: true,
          type: 'json'
      }, {
          interval: 5 * 1000,
          onEachFeature: function(feature, layer) {
              var content = '<h3>Serviceperson<\/h3>' +
              '<p>Name: ' + feature.properties.Name + '<br \/>' +
              'Status: ' + feature.properties.Status + '<\/p>';       
              layer.bindPopup(content);
          }
        });
var overlayMaps = { 
"Drivers": realtime
};
      var layerControl = L.control.layers(null, overlayMaps, {collapsed: false }).addTo(map);

Change dynamically the url, is it possible?

First thanks for this superb plugin.

My question, is it possible to change the url dynamically when the loop is running?

E.g. the plugin starts with something like:

...
url: '/api/vehicle/1'
...

And then with a click event changing it to:

...
url: '/api/vehicle/2'
...

during the loop execution set by interval.

Thanks for the support.

Adapting slightly different GeoJSON response from server

hi,

Thanks a lot for the useful plugin. I have a small question. If the server returns GeoJSON as shown below what would be the best way to get leaflet-realtime to use it. I was wondering if I could transform or convert the url at the client side rather than the server as I have limited access to that

{"resource":[{"_id":"5708b0627d57d0c20f3c989d","geojson":{"geometry":{"type":"Point","coordinates":[103.631185,1.311355]},"type":"Feature","properties":{"uniqueid":"359710043737114","address":"9 Tech Park Cres, Singapore, SG","speed":"0.0/0.0 (kph/mph)","datetime":"2016-04-09T07:33:52.000Z","fixtime":1460187232000,"deviceid":2}}}],"meta":{"count":1446,"next":1}}

Cheers,
M&M

Icon Color Update

Hi @perliedman ,
I've tried out your work-arrount in #34 to update the iconcolor using this:

var map = L.map('map').setView([48.517,18.255], 5);

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
var iconStyle; 
var shipLayer = L.layerGroup();
var red = L.icon({
    iconUrl: '../src/iconRed.png',
    iconSize: [30, 30]
});
var green = L.icon({
    iconUrl: '../src/iconGreen.png',
    iconSize: [30, 30]
});
var dkgreen = L.icon({
    iconUrl: '../src/iconDkGreen.png',
    iconSize: [30, 30]
});
var yellow = L.icon({
    iconUrl: '../src/iconYellow.png',
    iconSize: [30, 30]
});
var orange = L.icon({
    iconUrl: '../src/iconOrange.png',
    iconSize: [30, 30]
});

var realtime = L.realtime({
    url: 'http://localhost/zuege/zuege3.json',
    crossOrigin: true,
    type: 'json' 
  }, {
    interval: 5 * 1000,
    getFeatureId: function(featureData){
    	return featureData.properties.Zugnummer;
    },
    pointToLayer: function (feature, latlng) {
		
		
      marker = L.marker(latlng);
	  switch(feature.properties.Verspaetung){
			case "0": marker.setIcon(dkgreen); break;
			case "1": case "2": case "3": marker.setIcon(green); break;
			case "4": case "5": case "6": marker.setIcon(yellow); break;
			case "7": case "8": case "9": marker.setIcon(orange); break;
			default: marker.setIcon(red);
		}
		
      marker.bindPopup('Zugnummer: ' + feature.properties.Zugnummer +
                       '<br/> Verspätung:' + feature.properties.Verspaetung+
                       '<br/> Aktuelles:' + feature.properties.Aktuelles);
      marker.addTo(shipLayer);
	  
      return marker;
    },
	updateFeature: function(feature, oldLayer, newLayer) {
        switch(feature.properties.Verspaetung){
			case "0": marker.setIcon(dkgreen); break;
			case "1": case "2": case "3": marker.setIcon(green); break;
			case "4": case "5": case "6": marker.setIcon(yellow); break;
			case "7": case "8": case "9": marker.setIcon(orange); break;
			default: marker.setIcon(red);
		}
        return L.Realtime.prototype.options.updateFeature(feature, oldLayer, newLayer);
    }
}).addTo(map);

but unfortunaly the picture isn't updatet, even if the new marker picture is loaded...
Do you know how to solve this problem?

Thanks a lot for the moment
Flo

Switch to using geometryToLayer

As currently implemented, each update will create and add layers to the map for all incoming data, even if they often will immediately be removed again, since updateFeature will instead re-use the old layer.

It would be better to loop through incoming features and determine if we need to create new layers (with geometryToLayer), or if the existing layer can be updated. This would improved performance for larger datasets.

Not clear if this can be done in a backwards compatible way, so maybe for 2.0.

To get the trains demo working

I needed to check the trains demo to see how it works with multiple trackers. As it wasn't working I tried couple of things to get it working. For those keen to see the trains demo, there is a way. It just involves couple of steps

  1. Host the script and the plugin on your server
  2. Install this chrome CORS extension ( You can find something similar for Mozilla firefox too)
  3. And change type: 'jsonp' to type: 'json' in L.Realtime.reqwest example code

And then the trains demo should work! After your tests remember to disable the CORS extension otherwise it may interfere with your other stuff. I had issues posting this solution with CORS ext enabled :-)

Trying to persist Markers once the have been set

Hi

I am having trouble using the update command. I have a varyating set of markers coming in via a service. On first interval I may get markers with ids 1,2,3,4, and on the second call I only receive f.ex. 3 and 4. My problem is that then markers 1 and 2 disappear.

I am trying to persist the markers once they have been set or at least until I clear them manually. @perliedman you gave me the hint to use Update(), but I am not clever enough to make it happen.
Any bright minds out there that are willing to help?

reg. Axel

var map = new L.Map('map',
{
crs: L.CRS.Simple,
minZoom: -5,
worldCopyJump: false,
fullscreenControl: {
pseudoFullscreen: false // if true, fullscreen to page width and height
}

});

var bounds = [[0, 0], [18850, 16582]];
var image = L.imageOverlay('http://localhost:21074/uploads/floorplans/Intrazoffice_Office.svg', bounds).addTo(map);
map.fitBounds(bounds);

var realtime = L.realtime(function (success, error) {
L.Realtime.reqwest({
url: 'http://localhost:21074/livedata/LiveFeed',
crossOrigin: true,
type: 'json'
})
.then(function (data) {
success({
type: 'FeatureCollection',
features: [data]
});
})
.catch(error);
}, {
interval: 3 * 1000,
pointToLayer: function(feature, latlng) {
return L.marker(latlng,
{
icon: L.AwesomeMarkers.icon({
icon: 'shopping-cart',
prefix: 'fa',
markerColor: 'blue',
iconColor: 'white'
})
});
},
onEachFeature: function(feature, layer) {
var content = '

' + feature.properties.typename + ': ' +
feature.properties.typelabel + '
Charge: ' +
feature.properties.batterylevel + '%' +
'</p>';
layer.bindPopup(content);
}
}).addTo(map);

Feature Request - Fading tail

Would be useful if the current position showed a trail of the past "n" positions set by the user. The benefit is to give an idea of direction. Currently on a slow or stopped object, one can't tell the general direction of travel. With a small tail, this would solve the problem nicely.

An in-range update of grunt-contrib-uglify is breaking the build 🚨

Version 2.3.0 of grunt-contrib-uglify just got published.

Branch Build failing 🚨
Dependency grunt-contrib-uglify
Current Version 2.2.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As grunt-contrib-uglify is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪


Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details
Commits

The new version differs by 2 commits .

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Update map layer

Hello!
Is it possible when updating a map layer to maintain the scale and position of the center of the map. The plugin leaflet-realtime.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.