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
    3626
    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.
    • RocketBlaster05
      RocketBlaster05 last edited by

      Once again you are correct! Thanks once again!

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

        @cvp Now that I have this working, do you know a way I could make it remove only one pin? Sorry I'm like brand new to objc. Thanks!

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

          @RocketBlaster05 said:

          remove only one pin

          Sorry but I don't understand, there is only one pin...

          Do you want to have more than one pin and to be able to remove only one?

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

            @cvp yes.

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

              But how do you want to specify which you want to remove?

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

                @cvp with my code, I have 11 pins that spawn off startup. I wish to make it so that you can add a dropped pin, then if you do it again it removes the old one. Sorry on this 3 minute timer.

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

                  @RocketBlaster05 sorry, but I don't understand.
                  At each long press, you want to add a new pin
                  Thus, how to specify that you want to remove a pin?

                  RocketBlaster05 1 Reply Last reply Reply Quote 0
                  • 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