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
  zoom      = Xml.get(node: xml, tag: 'zoom');
  autozoom  = Xml.get(node: xml, tag: 'autozoom');
  latitude  = Xml.get(node: xml, tag: 'latitude');
  longitude = Xml.get(node: xml, tag: 'longitude');

  // add layers
  var layers = Xml.getChildElements(node: xml, tag: "LAYER");
  if (layers != null){
    for (var layer in layers) {
      String? url = Xml.get(node: layer, tag: 'url');
      if (url != null) this.layers.add(url);
    }}

  // build locations
  List<MapMarkerModel> markers = findChildrenOfExactType(MapMarkerModel).cast<MapMarkerModel>();
  for (var model in markers) {
    // 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?.getDataSource(model.datasource);
      if (source != null) source.register(this);
    }

    // static location
    else {
      this.markers.add(model);
    }
  }
}