none
No Draggable Pushpins in V8 Web Control? Can't set, get or add dragEnd events to pushpins RRS feed

  • Question

  • I started working on migrating my companying Bing map code to version 8 today. The pushpins have a dragend event (which worked find with v7), but I received the following error: "Cannot read property 'add' of undefined"

    So I copied an Bing example and modified it to test draggable in v8:

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <meta charset="utf-8" />
    
        <script type='text/javascript'
                src='http://www.bing.com/api/maps/mapcontrol?callback=GetMap'
                async defer></script>
    
        <script type='text/javascript'>
        var map;
    
        function GetMap() {
            map = new Microsoft.Maps.Map('#myMap', {
                credentials: 'my creds'
            });
    
            //Create a pushpin.
            var pushpin = new Microsoft.Maps.Pushpin(map.getCenter(),{color:'red',draggable:true});
            map.entities.push(pushpin);
            alert(pushpin.getColor());
            alert(pushpin.getDraggable());
        }
        </script>
    </head>
    <body>
        <div id="myMap" style=";width:800px;height:600px;"></div>
    </body>
    </html>

    It will return the color, but returns an error for getDraggable: pushpin.getDraggable is not a function

    According to documentation, getDraggable() is a function: https://msdn.microsoft.com/en-us/library/mt712674.aspx

    And the documentation for pushpin options doesn't mention setting "draggable" as an option in v8: https://msdn.microsoft.com/en-us/library/mt712673.aspx

    Anyone else experiencing this issue and/or have a solution?

    Friday, July 29, 2016 5:08 PM

Answers

All replies

  • When V8 initially released at the end of June, pushpins did not support dragging. This has since been added in the experimental branch and will be rolled into the main release branch next week. I'm in the process of updating the documentation in preparation for the release, thus the disconnect at the moment between some of the files. You can try this out now by adding "&branch=experimental" to the map script URL.

    We also have a code sample here: http://www.bing.com/api/maps/mapcontrol/isdk?autoRedirect=false#pushpinDragEvents+JS


    [Blog] [twitter] [LinkedIn]


    Friday, July 29, 2016 5:45 PM
  • Thank you for your quick answer Ricky! Glad it wasn't just me. LOL.

    I think I'll wait until "General Availability" gets closer to "It's All Working Availability" before continuing migration. :-)

    Friday, July 29, 2016 5:48 PM
  • Bing Maps V8 is released. We will continue to add features over time though as we now do continuous development. Instead of simply releasing a map control and waiting years before releasing a new one, plan to stay on V8 for as long as we can and simply add new features to it on a regular basis. As a whole V8 already has nearly twice the features V7 has. Additionally, V8 is in far better shape in it's first month of release than V7 was after its first year.

    The experimental branch is updated about 3 to 4 times a day. The release branch will update on a monthly schedule, and the frozen branch on a yearly schedule. The first update to the release branch is next week and address a large majority of the issues devs have found.


    [Blog] [twitter] [LinkedIn]

    Friday, July 29, 2016 10:20 PM
  • Has this feature gone away again? Dragging a pushpin does not seem to fire events in the sample https://www.bing.com/api/maps/sdk/mapcontrol/isdk/pushpindragevents#JS not in my sample based on that uses a fresh key.
    Friday, September 18, 2020 1:54 PM
  • Hi Erik,

    It seems to be working for me but I am using Edge browser.  Is there something unique in your setup that might be impacting this?

    Sincerely,

    IoTGirl

    Friday, September 18, 2020 5:35 PM
    Owner
  • Thanks for your note, IoTGirl. Seems to have been just a pilot error on my part. Got confused with addressing the pushpins. It works as intended.

    Tuesday, September 22, 2020 3:24 PM
  • Excellent!  Thank you for following up!
    Tuesday, September 22, 2020 5:43 PM
    Owner