1

I am trying to listen to right mouse click , i tried "rightclick" as in documentation says , but it doesn't work.

Can any one say why it doesn't work ???

map.on('rightclick', function (evt) {
            var feature = map.forEachFeatureAtPixel(evt.pixel, function (feature) {
                if (typeof (feature.getId()) != "undefined") {
                    return feature;
                }
            });

            if (feature) {
                var registeredObjectId = -1;

                if (typeof MapObjects !== "undefined") {
                    for (var i = 0; i < MapObjects.ObjectResult.length; i++) {
                        if (feature.p.name === MapObjects.ObjectResult[i].Id) {
                            registeredObjectId = i;
                        }
                    }
                }

                var geometry = feature.getGeometry();
                var coord = geometry.getCoordinates();

                if (registeredObjectId === -1) {
                    popup.setPosition(evt.coordinate);
                    $(element).popover({
                        'placement': 'top',
                        'html': true,
                        'content': "<a style='cursor: pointer' onclick='DeleteCoordinate(\"" + feature.getId() + "\")'>Delete</a>"
                    });
                    $(element).popover('show');
                    $(element2).popover('destroy');
                }
                else {
                    popup2.setPosition(evt.coordinate);
                    console.log(MapObjects.ObjectResult[registeredObjectId].Name);
                    console.log(MapObjects.ObjectResult[registeredObjectId].Value);
                    $(element2).popover({
                        'placement': 'top',
                        'html': true,
                        'content': "<label>" + MapObjects.ObjectResult[registeredObjectId].Name + "</label></br><label>" + MapObjects.ObjectResult[registeredObjectId].Value + "</label></br><a style='cursor: pointer' onclick='DeleteCoordinate(\"" + feature.getId() + "\")'>Delete</a>"
                    });
                    $(element2).popover('show');
                    $(element).popover('destroy');
                }

            } else {
                $(element).popover('destroy');
                $(element2).popover('destroy');
            }
        });
1

Try out this tutorial, someone got stuck with a similar problem and wrote some code to get around it http://spatialnotes.blogspot.com/2010/11/capturing-right-click-events-in.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.