How to pass parameters within infoboxoptions action function RRS feed

  • Question

  • I want to pass some parameters within Handler function,
    Here is my code
    Can any one help , How to do this 

    infoboxOptions = new Microsoft.Maps.Infobox(Point,
                       title: 'Title',
                       visible: true,
                       offset: new Microsoft.Maps.Point(0, 15),
                       actions: [{ label: 'Handler1', eventHandler: HandlerFunction }]

    function HandlerFunction (){


    what I want is something Like below code...

    infoboxOptions = new Microsoft.Maps.Infobox(Point,

     actions: [{ label: 'Handler1', eventHandler: HandlerFunction(Title, Desc, Lat) }]


    function HandlerFunction(Title, Desc, Lat) {}

    Thursday, July 7, 2016 8:53 AM


  • This is fairly easy to do in JavaScript. You simply need to create a function that takes in your properties and returns a callback function. You will then be able to access those properties from your callback function. Here is an example:

    <!DOCTYPE html>
        <meta charset="utf-8" />
        <script type='text/javascript' 
                async defer></script>
        <script type='text/javascript'>
        var map, infobox;
        function GetMap() {
            map = new Microsoft.Maps.Map('#myMap', {
                credentials: 'Your Bing Maps Key'
            var center = map.getCenter();
            infobox = new Microsoft.Maps.Infobox(center, {
                actions: [{
                    label: 'Handler',
                    eventHandler: createHandler('hello','',0)
            //Assign the infobox to a map instance.
        function createHandler(title, desc, lat) {
            return function () {
                alert('Title: ' + title);
        <div id="myMap" style=";width:600px;height:400px;"></div>

    [Blog] [twitter] [LinkedIn]

    Thursday, July 7, 2016 6:47 PM