deserialize method
Deserializes the FML template elements, attributes and children
Implementation
@override
void deserialize(XmlElement xml) {
// deserialize
super.deserialize(xml);
// properties
style = Xml.get(node: xml, tag: 'style');
zoom = Xml.get(node: xml, tag: 'zoom');
latitude = Xml.get(node: xml, tag: 'latitude');
longitude = Xml.get(node: xml, tag: 'longitude');
mapType = toEnum(Xml.get(node: xml, tag: 'type'), MapTypes.values);
showAll = toBool(Xml.get(node: xml, tag: 'showallpoints')) == false
? false
: true;
// build locations
List<MapLocationModel> locations =
findChildrenOfExactType(MapLocationModel).cast<MapLocationModel>();
for (var model in locations) {
// data driven prototype location
if (!isNullOrEmpty(model.datasource)) {
if (!prototypes.containsKey(model.datasource)) {
prototypes[model.datasource] = [];
}
// build prototype
var prototype = prototypeOf(model.element) ?? model.element;
// add location model
if (prototype != null) {
prototypes[model.datasource]!.add(prototype);
}
// register listener to the models datasource
IDataSource? source =
(scope != null) ? scope!.getDataSource(model.datasource) : null;
if (source != null) source.register(this);
}
// static location
else {
this.locations.add(model);
}
}
}