So I've bascially got an isMobile var set up to handle various tools that I want to use on the desktop or on mobile and vice versa:
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
So what I'm trying to do is get the snappingManager to be always on if moble, else set the CTRL key:
| var snapManager = mapMain.enableSnapping({ | |
if(!isMobile){[
console.log("im a desktop");
alwaysSnap: true,
tolerance: 5,
} else {
snapKey: has("mac") ? keys.META : keys.CTRL,
tolerance: 5,
snapPointSymbol: snapSym
}
});
var layerInfos = [{
layer: lyrParcels
}];
snapManager.setLayerInfos(layerInfos);
Anyway, the syntax isn't quite right setting the snappingManagers' constructor paramters in an if else block. Any help is appreciated.
Forgive the non-js highlighting on this part please - the editor syntax highlighter stopped beahving
Thanks
David