1

I am developing an app that should also work on mobile devices. I would like to close all open popups when clicking on the map (in this case only one can be open at any point, as opening a new one closes all existing ones; therefore referring to index 0 in the code snippet below).

The event has been registered like this:

itemsMap.events.register("click", itemsMap , function(e){
   closeOpenPopups();
});

And here is the function that takes care of it:

function closeOpenPopups(){
    // close popup if existent
    if(itemsMap.popups[0]){itemsMap.removePopup(itemsMap.popups[0]);}

    // unselect all features
    control_select_feature_showItem.unselectAll();
}

This works perfectly fine when testing it on non-mobile devices, but the popup just won't close on mobile devices. The strange thing: the unselectAll() works fine, so I guess I can assume that the click event is changed into a tapping event when using a mobile device (or that method would never be fired, right?).

  • I don't believe that goog.events has a different click event between mobile and other computing devices. If you could put up a complete working example in jsfiddle or similar, it would help. – John Powell Jan 22 '15 at 10:15
1

First of all I would test if the click event is fired on the mobile device (for example with a simple alert) http://jsfiddle.net/expedio/n68f7jus/ enter image description here

( and make sure you are using a up to date version of OpenLayers like 2.13 )

If you are using the popup for a vector layer you could try if this example works on your mobile device (vector style not even optimized for mobile devices)

http://jsfiddle.net/expedio/rk5puxp2/

enter image description here

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.