deserialize method

  1. @override
void deserialize(
  1. XmlElement xml
)
override

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 = S.toEnum(Xml.get(node: xml, tag: 'type'), MapTypes.values);
  showAll = S.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 (!S.isNullOrEmpty(model.datasource))
    {
      if (!prototypes.containsKey(model.datasource)) prototypes[model.datasource] = [];

      // build prototype
      var prototype = WidgetModel.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);
    }
  }
}