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');
  latitude  = Xml.get(node: xml, tag: 'latitude');
  longitude = Xml.get(node: xml, tag: 'longitude');
  showAll   = S.toBool(Xml.get(node: xml, tag: 'showallpoints')) == false ? false : true;

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

  // build locations
  List<MapMarkerModel> markers = findChildrenOfExactType(MapMarkerModel).cast<MapMarkerModel>();
  markers.forEach((model)
  {
    // data driven prototype location
    if (!S.isNullOrEmpty(model.datasource))
    {
      if (!prototypes.containsKey(model.datasource)) prototypes[model.datasource] = [];

      // build prototype
      String prototype = S.toPrototype(model.element.toString());

      // add location model
      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.markers.add(model);
  });
}