diff --git a/MAVProxy/modules/mavproxy_map/__init__.py b/MAVProxy/modules/mavproxy_map/__init__.py index d2ea36415a..1fbdbf3044 100644 --- a/MAVProxy/modules/mavproxy_map/__init__.py +++ b/MAVProxy/modules/mavproxy_map/__init__.py @@ -163,19 +163,31 @@ def cmd_map(self, args): if len(args) < 1: print("usage: map ") elif args[0] == "icon": - if len(args) < 3: - print("Usage: map icon ") - else: + usage = "Usage: map icon " + flag = 'flag.png' + if len(args) > 2: lat = args[1] lon = args[2] - flag = 'flag.png' if len(args) > 3: flag = args[3] + '.png' - icon = self.map.icon(flag) - self.map.add_object(mp_slipmap.SlipIcon('icon - %s [%u]' % (str(flag),self.icon_counter), - (float(lat),float(lon)), - icon, layer=3, rotation=0, follow=False)) - self.icon_counter += 1 + elif self.mpstate.click_location is not None: + if len(args) >= 1: + # i.e. "map icon" + (lat, lon) = self.mpstate.click_location + if len(args) == 2: + # i.e. map icon barrell + flag = args[1] + else: + print(usage) + return + + icon = self.map.icon(flag) + self.map.add_object(mp_slipmap.SlipIcon( + 'icon - %s [%u]' % (str(flag),self.icon_counter), + (float(lat),float(lon)), + icon, layer=3, rotation=0, follow=False)) + self.icon_counter += 1 + elif args[0] == "vehicletype": if len(args) < 3: print("Usage: map vehicletype SYSID TYPE")