Location update in the Map UI component: “listen” clause of rules
Here is the lesson code:
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)
}
}