customise simple web viewer

Drew Johnstone7 years ago

hey guys
Im looking for a way to display my vehicles current location on a website.
Im able to access the simple web view so that i can see the device showing up on a map but when the device moves the map doesnt reflect that etc. Obv when im logged in to the admin panel it shows the map and my location etc. is there a way to get the simple system to display like the admin map?

Leif Neland7 years ago

It is possible, I think

You get the position of the devices around line 120:

     for (i = 0; i < data.positions.length; i++) {
                        var position = data.positions[i];
                        var marker = markers[position.deviceId];
                        var point = new ol.geom.Point(ol.proj.fromLonLat([position.longitude, position.latitude]));

add this

If (position.deviceId == YOURID) { // There could be more vehicles, follow only one
          map.getView().setCenter(ol.proj.fromLonLat([position.longitude, position.latitude  ])); 
}

I haven't tried it, but it should work.