How to get the lat/long in MapBox iOS SDK after drag&drop












0















I'm using drag&drop the same way as in the official example of MapBox:
https://www.mapbox.com/ios-sdk/maps/examples/draggable-views/



I can't find a way to get the lat/long of the dragged annotation after dropping.
There is no delegate. Neither in MGLMapViewDelegate nor in any other delegate.



MGLAnnotationView has some dragState-members which do not match the lat/long-request.
https://www.mapbox.com/ios-sdk/api/4.6.0/Classes/MGLAnnotationView.html



When I use initWithAnnotation:reuseIdentifier: instead of initWithReuseIdentifier: the MGLAnnotationView has its annotation-property set correctly. But the annotation.coordinate does not get updated.



https://www.mapbox.com/ios-sdk/api/4.6.0/Classes/MGLAnnotationView.html#/c:objc(cs)MGLAnnotationView(im)initWithAnnotation:reuseIdentifier:



So how can I get the lat/long after dropping?










share|improve this question



























    0















    I'm using drag&drop the same way as in the official example of MapBox:
    https://www.mapbox.com/ios-sdk/maps/examples/draggable-views/



    I can't find a way to get the lat/long of the dragged annotation after dropping.
    There is no delegate. Neither in MGLMapViewDelegate nor in any other delegate.



    MGLAnnotationView has some dragState-members which do not match the lat/long-request.
    https://www.mapbox.com/ios-sdk/api/4.6.0/Classes/MGLAnnotationView.html



    When I use initWithAnnotation:reuseIdentifier: instead of initWithReuseIdentifier: the MGLAnnotationView has its annotation-property set correctly. But the annotation.coordinate does not get updated.



    https://www.mapbox.com/ios-sdk/api/4.6.0/Classes/MGLAnnotationView.html#/c:objc(cs)MGLAnnotationView(im)initWithAnnotation:reuseIdentifier:



    So how can I get the lat/long after dropping?










    share|improve this question

























      0












      0








      0








      I'm using drag&drop the same way as in the official example of MapBox:
      https://www.mapbox.com/ios-sdk/maps/examples/draggable-views/



      I can't find a way to get the lat/long of the dragged annotation after dropping.
      There is no delegate. Neither in MGLMapViewDelegate nor in any other delegate.



      MGLAnnotationView has some dragState-members which do not match the lat/long-request.
      https://www.mapbox.com/ios-sdk/api/4.6.0/Classes/MGLAnnotationView.html



      When I use initWithAnnotation:reuseIdentifier: instead of initWithReuseIdentifier: the MGLAnnotationView has its annotation-property set correctly. But the annotation.coordinate does not get updated.



      https://www.mapbox.com/ios-sdk/api/4.6.0/Classes/MGLAnnotationView.html#/c:objc(cs)MGLAnnotationView(im)initWithAnnotation:reuseIdentifier:



      So how can I get the lat/long after dropping?










      share|improve this question














      I'm using drag&drop the same way as in the official example of MapBox:
      https://www.mapbox.com/ios-sdk/maps/examples/draggable-views/



      I can't find a way to get the lat/long of the dragged annotation after dropping.
      There is no delegate. Neither in MGLMapViewDelegate nor in any other delegate.



      MGLAnnotationView has some dragState-members which do not match the lat/long-request.
      https://www.mapbox.com/ios-sdk/api/4.6.0/Classes/MGLAnnotationView.html



      When I use initWithAnnotation:reuseIdentifier: instead of initWithReuseIdentifier: the MGLAnnotationView has its annotation-property set correctly. But the annotation.coordinate does not get updated.



      https://www.mapbox.com/ios-sdk/api/4.6.0/Classes/MGLAnnotationView.html#/c:objc(cs)MGLAnnotationView(im)initWithAnnotation:reuseIdentifier:



      So how can I get the lat/long after dropping?







      ios drag-and-drop mapbox






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 16 '18 at 9:15









      user2290269user2290269

      142




      142
























          2 Answers
          2






          active

          oldest

          votes


















          0














          If I'm understanding you correctly, this should be as simple as checking the annotation associated with the annotationView once the dragging has finished.



          Have you tried something like the following inside your draggable MGLAnnotationView subclass?



          let newLatitude = self.annotation?.coordinate.latitude
          let newLongitude = self.annotation?.coordinate.longitude


          -- allowing for the usual optional checks, etc. I have these lines inside the endDragging() method.






          share|improve this answer
























          • Yes you are right. During MGLAnnotationViewDragStateDragging the coordinate is not updated. But MGLAnnotationViewDragStateEnding the coordinate of the annotation gets updated.

            – user2290269
            Nov 17 '18 at 9:16





















          0














          The coordinate of the associated annotation gets updated only at ending not during dragging.



              case MGLAnnotationViewDragStateDragging:
          NSLog(@"%@ / %@", @(self.annotation.coordinate.latitude), @(self.annotation.coordinate.longitude));
          break;

          case MGLAnnotationViewDragStateEnding:
          case MGLAnnotationViewDragStateCanceling:
          NSLog(@"endDragging: %@ / %@", @(self.annotation.coordinate.latitude), @(self.annotation.coordinate.longitude));
          [self endDragging];
          break;


          Results in:



          2018-11-17 10:15:22.122488+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
          2018-11-17 10:15:22.145187+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
          2018-11-17 10:15:22.169465+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
          2018-11-17 10:15:22.193490+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
          2018-11-17 10:15:22.485666+0100 FreeFlightAtlas AdHoc[4780:1555191] endDragging: 25.12811184395072 / -41.88967123348579





          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53334703%2fhow-to-get-the-lat-long-in-mapbox-ios-sdk-after-dragdrop%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            If I'm understanding you correctly, this should be as simple as checking the annotation associated with the annotationView once the dragging has finished.



            Have you tried something like the following inside your draggable MGLAnnotationView subclass?



            let newLatitude = self.annotation?.coordinate.latitude
            let newLongitude = self.annotation?.coordinate.longitude


            -- allowing for the usual optional checks, etc. I have these lines inside the endDragging() method.






            share|improve this answer
























            • Yes you are right. During MGLAnnotationViewDragStateDragging the coordinate is not updated. But MGLAnnotationViewDragStateEnding the coordinate of the annotation gets updated.

              – user2290269
              Nov 17 '18 at 9:16


















            0














            If I'm understanding you correctly, this should be as simple as checking the annotation associated with the annotationView once the dragging has finished.



            Have you tried something like the following inside your draggable MGLAnnotationView subclass?



            let newLatitude = self.annotation?.coordinate.latitude
            let newLongitude = self.annotation?.coordinate.longitude


            -- allowing for the usual optional checks, etc. I have these lines inside the endDragging() method.






            share|improve this answer
























            • Yes you are right. During MGLAnnotationViewDragStateDragging the coordinate is not updated. But MGLAnnotationViewDragStateEnding the coordinate of the annotation gets updated.

              – user2290269
              Nov 17 '18 at 9:16
















            0












            0








            0







            If I'm understanding you correctly, this should be as simple as checking the annotation associated with the annotationView once the dragging has finished.



            Have you tried something like the following inside your draggable MGLAnnotationView subclass?



            let newLatitude = self.annotation?.coordinate.latitude
            let newLongitude = self.annotation?.coordinate.longitude


            -- allowing for the usual optional checks, etc. I have these lines inside the endDragging() method.






            share|improve this answer













            If I'm understanding you correctly, this should be as simple as checking the annotation associated with the annotationView once the dragging has finished.



            Have you tried something like the following inside your draggable MGLAnnotationView subclass?



            let newLatitude = self.annotation?.coordinate.latitude
            let newLongitude = self.annotation?.coordinate.longitude


            -- allowing for the usual optional checks, etc. I have these lines inside the endDragging() method.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 16 '18 at 13:23









            MagnasMagnas

            2,45432138




            2,45432138













            • Yes you are right. During MGLAnnotationViewDragStateDragging the coordinate is not updated. But MGLAnnotationViewDragStateEnding the coordinate of the annotation gets updated.

              – user2290269
              Nov 17 '18 at 9:16





















            • Yes you are right. During MGLAnnotationViewDragStateDragging the coordinate is not updated. But MGLAnnotationViewDragStateEnding the coordinate of the annotation gets updated.

              – user2290269
              Nov 17 '18 at 9:16



















            Yes you are right. During MGLAnnotationViewDragStateDragging the coordinate is not updated. But MGLAnnotationViewDragStateEnding the coordinate of the annotation gets updated.

            – user2290269
            Nov 17 '18 at 9:16







            Yes you are right. During MGLAnnotationViewDragStateDragging the coordinate is not updated. But MGLAnnotationViewDragStateEnding the coordinate of the annotation gets updated.

            – user2290269
            Nov 17 '18 at 9:16















            0














            The coordinate of the associated annotation gets updated only at ending not during dragging.



                case MGLAnnotationViewDragStateDragging:
            NSLog(@"%@ / %@", @(self.annotation.coordinate.latitude), @(self.annotation.coordinate.longitude));
            break;

            case MGLAnnotationViewDragStateEnding:
            case MGLAnnotationViewDragStateCanceling:
            NSLog(@"endDragging: %@ / %@", @(self.annotation.coordinate.latitude), @(self.annotation.coordinate.longitude));
            [self endDragging];
            break;


            Results in:



            2018-11-17 10:15:22.122488+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
            2018-11-17 10:15:22.145187+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
            2018-11-17 10:15:22.169465+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
            2018-11-17 10:15:22.193490+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
            2018-11-17 10:15:22.485666+0100 FreeFlightAtlas AdHoc[4780:1555191] endDragging: 25.12811184395072 / -41.88967123348579





            share|improve this answer




























              0














              The coordinate of the associated annotation gets updated only at ending not during dragging.



                  case MGLAnnotationViewDragStateDragging:
              NSLog(@"%@ / %@", @(self.annotation.coordinate.latitude), @(self.annotation.coordinate.longitude));
              break;

              case MGLAnnotationViewDragStateEnding:
              case MGLAnnotationViewDragStateCanceling:
              NSLog(@"endDragging: %@ / %@", @(self.annotation.coordinate.latitude), @(self.annotation.coordinate.longitude));
              [self endDragging];
              break;


              Results in:



              2018-11-17 10:15:22.122488+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
              2018-11-17 10:15:22.145187+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
              2018-11-17 10:15:22.169465+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
              2018-11-17 10:15:22.193490+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
              2018-11-17 10:15:22.485666+0100 FreeFlightAtlas AdHoc[4780:1555191] endDragging: 25.12811184395072 / -41.88967123348579





              share|improve this answer


























                0












                0








                0







                The coordinate of the associated annotation gets updated only at ending not during dragging.



                    case MGLAnnotationViewDragStateDragging:
                NSLog(@"%@ / %@", @(self.annotation.coordinate.latitude), @(self.annotation.coordinate.longitude));
                break;

                case MGLAnnotationViewDragStateEnding:
                case MGLAnnotationViewDragStateCanceling:
                NSLog(@"endDragging: %@ / %@", @(self.annotation.coordinate.latitude), @(self.annotation.coordinate.longitude));
                [self endDragging];
                break;


                Results in:



                2018-11-17 10:15:22.122488+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
                2018-11-17 10:15:22.145187+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
                2018-11-17 10:15:22.169465+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
                2018-11-17 10:15:22.193490+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
                2018-11-17 10:15:22.485666+0100 FreeFlightAtlas AdHoc[4780:1555191] endDragging: 25.12811184395072 / -41.88967123348579





                share|improve this answer













                The coordinate of the associated annotation gets updated only at ending not during dragging.



                    case MGLAnnotationViewDragStateDragging:
                NSLog(@"%@ / %@", @(self.annotation.coordinate.latitude), @(self.annotation.coordinate.longitude));
                break;

                case MGLAnnotationViewDragStateEnding:
                case MGLAnnotationViewDragStateCanceling:
                NSLog(@"endDragging: %@ / %@", @(self.annotation.coordinate.latitude), @(self.annotation.coordinate.longitude));
                [self endDragging];
                break;


                Results in:



                2018-11-17 10:15:22.122488+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
                2018-11-17 10:15:22.145187+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
                2018-11-17 10:15:22.169465+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
                2018-11-17 10:15:22.193490+0100 FreeFlightAtlas AdHoc[4780:1555191] -34.613152 / -58.377232
                2018-11-17 10:15:22.485666+0100 FreeFlightAtlas AdHoc[4780:1555191] endDragging: 25.12811184395072 / -41.88967123348579






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 17 '18 at 9:22









                user2290269user2290269

                142




                142






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53334703%2fhow-to-get-the-lat-long-in-mapbox-ios-sdk-after-dragdrop%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Bressuire

                    Vorschmack

                    Quarantine