omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Removing custom pins with Map API

    Pythonista
    2
    21
    3623
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cvp
      cvp @RocketBlaster05 last edited by

      @RocketBlaster05 with this, no remove

      def long_press_action(sender):
      	# Add a pin when the MapView recognizes a long-press
      	c = sender.point_to_coordinate(sender.long_press_location)
      	# this of only to special process asked in forum
      	# https://forum.omz-software.com/topic/7077/removing-custom-pins-with-map-api
      	if 1==0:#len(sender.mk_map_view.annotations()) == 1:
      		sender.remove_all_pins()
      	else:
      		sender.add_pin(c[0], c[1], 'Dropped Pin', str(c), select=True)
      	sender.set_center_coordinate(c[0], c[1], animated=True)
      
      1 Reply Last reply Reply Quote 0
      • RocketBlaster05
        RocketBlaster05 @cvp last edited by

        @cvp Yes I want to add and remove "Dropped Pin"s only

        cvp 1 Reply Last reply Reply Quote 0
        • cvp
          cvp @RocketBlaster05 last edited by

          @RocketBlaster05 thus a long press adds an additional pin.
          Which gesture should remove the last one?

          RocketBlaster05 1 Reply Last reply Reply Quote 0
          • RocketBlaster05
            RocketBlaster05 @cvp last edited by

            @cvp whenever a new pin is added, the only pins that should be removed are any pins named "Dropped Pin." It gets removed once a new pin is added.

            cvp 1 Reply Last reply Reply Quote 0
            • cvp
              cvp @RocketBlaster05 last edited by

              @RocketBlaster05 I think that I'm not very skilled in English but I don't understnd.
              In this script, all pins are named "dropped", except the first one.

              RocketBlaster05 1 Reply Last reply Reply Quote 0
              • RocketBlaster05
                RocketBlaster05 @cvp last edited by RocketBlaster05

                @cvp yes what you wrote below is correct

                1 Reply Last reply Reply Quote 0
                • cvp
                  cvp last edited by cvp

                  I think that I begin to understand.
                  Your code has placed 11 pins and you want that a long press only deletes the pin named dropped.
                  Is that correct?

                  RocketBlaster05 1 Reply Last reply Reply Quote 0
                  • RocketBlaster05
                    RocketBlaster05 @cvp last edited by

                    @cvp yes that is correct

                    cvp 1 Reply Last reply Reply Quote 0
                    • cvp
                      cvp @RocketBlaster05 last edited by cvp

                      @RocketBlaster05 sorry for the misunderstanding

                      def long_press_action(sender):
                      	# Add a pin when the MapView recognizes a long-press
                      	c = sender.point_to_coordinate(sender.long_press_location)
                      	# this of only to special process asked in forum
                      	# https://forum.omz-software.com/topic/7077/removing-custom-pins-with-map-api
                      	for annotation in sender.mk_map_view.annotations():
                      		if str(annotation.title()) == 'Dropped Pin':
                      			sender.mk_map_view.removeAnnotation_(annotation)
                      	else:
                      		sender.add_pin(c[0], c[1], 'Dropped Pin', str(c), select=True)
                      	sender.set_center_coordinate(c[0], c[1], animated=True)
                      
                      RocketBlaster05 1 Reply Last reply Reply Quote 0
                      • RocketBlaster05
                        RocketBlaster05 @cvp last edited by

                        @cvp works like a charm!

                        cvp 1 Reply Last reply Reply Quote 0
                        • cvp
                          cvp @RocketBlaster05 last edited by

                          @RocketBlaster05 ouf. Sorry to have been so slow to understand

                          RocketBlaster05 1 Reply Last reply Reply Quote 0
                          • RocketBlaster05
                            RocketBlaster05 @cvp last edited by

                            @cvp school's been rough lately lol. Teacher is asking I make more modifications to the map we were talking about so that I can collect some data... I have a simple ui.load_view() I plan to make later which will ask the user if they want to mark their current location on the map. However I would need a button to be pressed for the user to get the view to work. Also, the user would need to be able to do so as many times as they like, so that multiple marks can appear on the map. The positions of the markers would need to be saved so that the next time the map is activated, the markers will reappear. I understand this is likely a fair amount of code, but any help would be greatly appreciated. I will not be able to test the code for a few hours because my iPad is at home and I am at school. If you could suggest any ideas for me to test later I would be very thankful.

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post
                            Powered by NodeBB Forums | Contributors