4 Replies Latest reply: Oct 16, 2013 8:40 AM by grueningd RSS

    Dragging MVFOI objects

    grueningd

      Hi,

      since updated mapviewer  from version Ver11.1.1.7_B121012 to Ver11.1.1.7.1_B130812 I have a problem dragging FOIs. I still use oraclemaps v1 api.

      This is the way I used to accomplish the FOI dragging:

      1. Register mousemove listener on map base div
      2. Attach MVEvent.MOUSE_DOWN Event to MVFOI instance and add it to the map
      3. In the eventhandler for FOIs mouse_down event do the following:
        1. attach MVEvent.MOUSE_UP event to FOI instance
        2. disable map dragging (mapview.enableDragging(false);)
      4. In the map divs mousemove event handler update the FOI with the current mouse location while the user drags the foi around the map (foi.updateGeometry(mouseLoc);). Continue doing so until user releases the left mouse button -> step 5
      5. When user releases left mouse button the MVEvent.MOUSE_UP event mentioned in 3) is fired. In that handler to the following:
        1. Enabled map dragging again (mapview.enableDragging(true);)
        2. Detach MVEvent.MOUSE_UP event from foi instance.

      That workflow works fine since updating mapviewer. What fails in the new release is the dragging mentioned in step 4). When the user tries to drag the foi the mouse cursor changes to “not-allowed” style and the foi is not moved. But when the user releases the mouse button the foi can be moved around the map since the user clicks into the map once again.

      I realized a couple of changes in oraclemaps.js in the code responsible for the mouse drag behaviour. Now I’m wondering if there is a bug or whether the upper way isn’t appropriate to accomplish the requirement. Does anybody have instructions how to realize dragging of MVFOI objects?

       

      Thanks

      Dominik

        • 1. Re: Dragging MVFOI objects
          grueningd

          Hi again,

           

          one thing I realized is that the FOI-movement is working for IE8 and all tested versions of firefox. So the problem is reproduceable at least in IE9 and IE10

          • 2. Re: Dragging MVFOI objects
            CharlesW

            Hi,

             

            There is no MOUSE_UP event with our FOI object. After you register your MOUSE_DOWN with your FOI that has been added to the map, you may refer to the below sample code to make your FOI draggable on the map, the below code can also be run with IE9.

             

            function downListener(point,foi,evt)

            {

            mapview.attachEventListener(MVEvent.MOUSE_MOVE,moveListener);

            mapview.attachEventListener(MVEvent.MOUSE_UP, upListener);

            mapview.enableDragging(false);

            }

            function moveListener()

            {

            var mouseLoc = mapview.getMouseLocation();

            mfoi2.updateGeometry(mouseLoc);

            }

            function upListener()

            {

            mapview.enableDragging(true);

            mapview.detachEventListener(MVEvent.MOUSE_MOVE, moveListener);

            }

            • 3. Re: Dragging MVFOI objects
              grueningd

              Hi Charles,

               

              thanks for reply!

               

              Yes, your solution works. In fact my implementation is like the way you are describing it. I just

              mixed up the registration target of the MOUSE_UP listener in my upper workflow description. I've build a small sample where the foi dragging works in IE9. I think there are some kind of site effects in my more complex application causing this faulty behavior. I will try to reproduce the error in that sample page...

               

              Kind regards

              Dominik

              • 4. Re: Dragging MVFOI objects
                grueningd

                For the sake of completeness:

                 

                I finally found what was causing the error: In the HTML-<head> section there was an meta-tag like this:

                 

                <meta http-equiv="X-UA-Compatible" content="IE=8; charset=utf-8;" />

                 

                I change it to

                 

                <meta http-equiv="X-UA-Compatible" content="IE=9; charset=utf-8;" />

                 

                I've no idea why but that does the trick.