AnsweredAssumed Answered

Syntax Help: If else containing constructor options

Question asked by dcoley on Mar 5, 2015
Latest reply on Mar 6, 2015 by dcoley

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({


console.log("im a desktop");

alwaysSnap: true,

tolerance: 5,

snapPointSymbol: snapSym

} else {

snapKey: has("mac") ? keys.META : keys.CTRL,

tolerance: 5,

snapPointSymbol: snapSym



var layerInfos = [{

layer: lyrParcels




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