The version contains a lot of breaking changes, to make things simpler to use and to remove all application specific stuff.
Here is an exhaustive list of what you have to change in your application code.
- all classes, api and utilities functions are available through a unique import (depending on what mapping library you use):
'mobility-toolbox-js/ol'
or'mobility-toolbox-js/mapbox'
- remove all
Map
classes. Use the Mapbox or Openlayers Map directly then useattachToMap()
anddetachFromMap()
functions.
// Before:
const map = new Map();
map.addLayer(myLayer);
map.addControl(myControl);
map.removeLayer(myLayer);
map.removeControl(myControl);
// After
const map = new Openlayers.Map();
myLayer.attachToMap(map);
myControl.attachToMap(map);
myLayer.detachFromMap();
myControl.detachFromMap();
- add
group
property.
// Before:
const layer = new layer({ properties: { radioGroup: 'my group' }});
// After
const layer = new layer({ group: 'my group' });
-
remove
TrajservLayer
, useRealtimeLayer
instead -
remove
addChild()
,removeChild()
,hasVisibleChildren()
,getVisibleChildren()
convenience methods, usechildren
array directly instead -
remove
setVisible()
method, use layer's property instead
// Before:
layer.setVisible(true);
// After
layer.visible = true;
- remove
isBaseLayer
property
// Before:
const layer = new Layer({ isBaseLayer: true});
const isBaseLayer = layer.isBaseLayer;
// After
const layer = new Layer({ properties: { isBaseLayer: true }});
const isBaseLayer = layer.get('isBaseLayer');
- remove
isQueryable
property
// Before:
const layer = new Layer({ isQueryable: true});
const isQueryable = layer.isQueryable;
// After
const layer = new Layer({ properties: { isQueryable: true }});
const isQueryable = layer.get('isQueryable');
- remove
isAlwaysExpanded
property
// Before:
const layer = new Layer({ isAlwaysExpanded: true});
const isAlwaysExpanded = layer.isAlwaysExpanded;
// After
const layer = new Layer({ properties: { isAlwaysExpanded: true }});
const isAlwaysExpanded = layer.get('isAlwaysExpanded');
-
remove
isReactSpatialLayer
property -
replace
init()
byattachToMap()
// Before:
layer.init(map)
// After
layer.attachToMap(map)
- replace
terminate()
bydetachFromMap()
// Before:
layer.terminate()
// After
layer.detachFromMap()
- remove
options.preserveDrawingBuffer
, useoptions.mapOptions
in the constructor
// Before:
const layer = new MapoxLayer({ preserveDrawingBuffer: true});
// After
const layer = new Layer({ mapOptions: { preserveDrawingBuffer: true}});
- replace
createStyleUrl()
by an utility functiongetUrlWithParams()
// Before:
const layer = new MapoxLayer();
const url = layer.createStyleUrl();
// After
import { getUrlWithParams } from 'mobility-toolbox-js/common';
const layer = new MapoxLayer();
const url = getUrlWithParams(layer.url, { [layer.apiKeyName]: layer.apiKey }).toString();
- rename
TralisLayer
toRealtimeLayer
- remove
isTrackerLayer
property - remove properties :
publishedLineName
,tripNumber
,operator
,regexPublishedLineName
. Use utility functioncreateRealtimeFilters()
instead.
// Before:
const layer = new TralisLayer({
publishedLineName: 'foo',
tripNumber: 2,
operator: 'bar',
regexPublishedLineName: /.*/,
});
// After
import { createRealtimeFilters } from 'mobility-toolbox-js/common';
const layer = new RealtimeLayer({
filter: createRealtimeFilters('foo','2','bar', /.*/),
});
- remove all automatic filter through permalink using
publishedlinename
,tripnumber
,operator
// After
import { createRealtimeFilters } from 'mobility-toolbox-js/common';
const params = new URLSearchParans(window.location.search);
const layer = new RealtimeLayer({
filter: createRealtimeFilters(
params.get('publishedlinename'),
params.get('tripnumber'),
params.get('operator'),
),
});
- remove style properties
delayOutlineColor
,delayDisplay
,iconScale
. Useoptions.styleOptions
in the constructor to proivde these valeu to the rendering.
// Before
const layer = new RealtimeLayer({
delayOutlineColor:'#000',
delayDisplay: 300000,
iconScale: 0.5,
});
// After
const layer = new RealtimeLayer({
styleOptions: {
delayOutlineColor:'#000',
delayDisplay: 300000,
iconScale: 0.5,
}
});
-
remove
getVehiclesAtCoordinate()
, usegetFeatureAtCoordinate()
instead -
remove
useDelayStyle
property, usestyle
,sort
andfullTrajectoryStyle
instead
// Before
import { TralisLayer } from 'mobility-toolbox-js/ol';
const layer = new TralisLayer({
useDelayStyle: true,
});
// After
import {
RealtimeLayer,
fullTrajectoryDelayStyle,
realtimeDelayStyle,
sortByDelay,
} from 'mobility-toolbox-js/ol';
const layer = new RealtimeLayer({
style: realtimeDelayStyle,
sort: sortByDelay,
fullTrajectoryStyle: fullTrajectoryDelayStyle,
});
- rename
TralisAPI
toRealtimeAPI
- rename
TralisModes
toRealtimeModes
search()
method returns a GeoJSON feature collection instead of an array of GeoJSON feature
// Before
const api = new StopsAPI({ ... });
api.search().then((arrayOfFeatures) => {
const feature = arrayOfFeatures[0];
});
// After
const api = new StopsAPI({ ... });
api.search().then((featureCollection) => {
const feature = featureCollection.features[0];
});