none
Bing map V8 rightclick event issue RRS feed

  • Question

  • Hi,

    We have started using bing map V8. We have facing some issue when we add the rightclick event of pushpin. We are getting below error.

    Cannot read property ‘add’ of undefined.

    We are able to replicate this in V8 interactive SDK as shown in below screenshot.

    Can you please check and let us know how to resolve this issue.

    Thanks!

    Balasaheb


    Balasaheb

    Tuesday, November 1, 2016 11:54 AM

Answers

All replies

  • Individual shapes do not support right click. Here is documentation on how to use right click on layers for shapes: https://msdn.microsoft.com/en-us/library/mt790077.aspx

    [Blog] [twitter] [LinkedIn]

    Tuesday, November 1, 2016 5:04 PM
  • Hi Ricky,

    Thanks for your reply. It worked.

    Thanks


    Balasaheb

    Wednesday, November 9, 2016 8:45 AM
  • Hi,

    We are exploring the V8 direction manager and we are able to plot the direction. But when we add the below event hander.

     Microsoft.Maps.Events.addHandler(directionsManager, 'afterSummaryRender', function () {
                        document.getElementById('printoutPanel').innerHTML = 'Directions!';
                    });

     Microsoft.Maps.Events.addHandler(directionsManager, 'routeSelectorClicked', routeSelectorClicked);

     then it throws following error.

    It is same error that we faced for right click event of pushpin as per your suggestion we resolved this by add right click for layer not the Individual pushpin. It is working but we are facing issue, here is more inside of it. Suppose we add 10 pushpin  in layer and add right click event then it fire and called 10 times and gives wrong detail when we right click and it gives different details each time suppose we plot 11 pushpins. Can you please suggest any solution for it.

    Thanks! 




    Friday, December 2, 2016 11:48 AM
  • These events don't exist in the directions manager. The directions manager only has two events as documented here: https://msdn.microsoft.com/en-US/library/mt750375.aspx

    [Blog] [twitter] [LinkedIn]

    Friday, December 2, 2016 1:01 PM
  • Hi,

    Thanks for your reply. Can you please give suggestion to resolve below issue.

    Here is more inside of it. Suppose we add 10 pushpin  in layer and add right click event then it fire and called 10 times and gives wrong detail when we right click and it gives different details each time suppose we plot 11 pushpins. Can you please suggest any solution for it.

    Thanks



    Balasaheb

    Tuesday, December 6, 2016 2:03 PM
  • When the click event fires, you can get the pushpin that it occurred on from the primitive property. If you add an 11th pushpin to the layer then right click it, the event will fire and contain that pushpin.

    [Blog] [twitter] [LinkedIn]

    Tuesday, December 6, 2016 2:38 PM
  • Hi,

    We have used the clustering module of Bing map V8. But when we tried to add right click event then we get below mention error as we disscued earlier post.

    Cannot read property ‘add’ of undefined.

    As you sguuest workaroud for pushpin. Is there any wrok around for cluster also. Below is the code we used to add the events.

    function createClusteredPin(cluster, latlong) {

        cluster.setOptions({
            //   icon: 'images/greenCircle.gif',
            anchor: new Microsoft.Maps.Point(8, 8),
            width: 16,
            height: 16
        });

        $.each(cluster.containedPushpins, function (index, pin) {
            clusterRecords.push(pin.data);
        });

        //Add handler for the pushpin click event.
        Microsoft.Maps.Events.addHandler(cluster, 'click', function (Clusterpin) { clusterRecords(Clusterpin, clusterRecords, cluster.containedPushpins[0].scope); });
        Microsoft.Maps.Events.addHandler(cluster, 'rightclick', function (Clusterpin) { showContextMenu(Cluster.containedPushpins[0]); });
        return cluster;
    }

    Thanks!


    Balasaheb

    Wednesday, December 21, 2016 6:55 AM
  • A cluster is a pushpin and as mentioned before, individual pushpins do not have right click events.

    Microsoft.Maps.Events.addHandler(clusterLayer, 'rightclick', function (e) { 
    	// You can get the clicked shape using e.primitive.
    	// If you want to know if it is a cluster or not, you can do this.
    	if(e.primitive.containedPushpins)
    	{
    		//Is clsuter
    	} else{
    		//Is unclustered pushpin.	
    	}
    });


    [Blog] [twitter] [LinkedIn]

    Wednesday, December 21, 2016 9:21 AM
  • Hi Ricky,

    Thanks for your reply. We will try this and let you know.

    We have one more question as below

    Suppose we added 10 pushpin in layer and add right click event. When we right click on pushpin then event fire and called function 10 times. Is there any way to fire the event only once not 10 times.

    Thanks!



    Balasaheb

    Wednesday, December 21, 2016 2:14 PM
  • You should only add the event to the layer once, not 10 times. From there, the event will only fire once per right click.

    [Blog] [twitter] [LinkedIn]

    Wednesday, December 21, 2016 3:31 PM
  • Hi Ricky,

    Thanks for your reply. It worked.

    We really appreciate your help.

    Thanks


    Balasaheb

    Thursday, December 22, 2016 5:29 AM