Cláusula “listen” de reglas
Aquí te dejamos el código utilizado en esta lección:
RuleContext CreateTreasureContext {
Rule visualizeTreasureOnMap listen (name, latitude, longitude from CreateTreasure as ct) when (ct.latitude != null && ct.longitude != null) {
if (ct.treasureLocationInMap.size() > 0) {
ct.treasureLocationInMap.removeAll()
}
String markerName = "treasure"
if (ct.name != null) {
markerName = ct.name
}
Location loc = Location(latitude: ct.latitude, longitude: ct.longitude)
Marker eventMarker = Marker(location: loc, title: markerName, showBubble: true, leftIcon: "https://goo.gl/Sg9RG9")
ct.treasureLocationInMap.add(eventMarker)