<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Syntax Help: If else containing constructor options in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-help-if-else-containing-constructor-options/m-p/175554#M16315</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Since the isMobile is an object and not a boolean value are you sure that it is not always something besides null and thus only entering the first part of the if?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Mar 2015 00:00:06 GMT</pubDate>
    <dc:creator>RobertScheitlin__GISP</dc:creator>
    <dc:date>2015-03-06T00:00:06Z</dc:date>
    <item>
      <title>Syntax Help: If else containing constructor options</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-help-if-else-containing-constructor-options/m-p/175553#M16314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var isMobile = {
&amp;nbsp; Android: function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return navigator.userAgent.match(/Android/i);
&amp;nbsp;&amp;nbsp;&amp;nbsp; },
&amp;nbsp;&amp;nbsp;&amp;nbsp; BlackBerry: function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return navigator.userAgent.match(/BlackBerry/i);
&amp;nbsp;&amp;nbsp;&amp;nbsp; },
&amp;nbsp; iOS: function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return navigator.userAgent.match(/iPhone|iPad|iPod/i);
&amp;nbsp; },
&amp;nbsp; Opera: function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return navigator.userAgent.match(/Opera Mini/i);
&amp;nbsp; },
&amp;nbsp; Windows: function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return navigator.userAgent.match(/IEMobile/i);
&amp;nbsp; },
&amp;nbsp; any: function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
&amp;nbsp; }
};
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So what I'm trying to do is get the snappingManager to be always on if moble, else set the CTRL key:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;var snapManager = mapMain.enableSnapping({&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;if(!isMobile){[&lt;/P&gt;&lt;P&gt;console.log("im a desktop");&lt;/P&gt;&lt;P&gt;alwaysSnap: true,&lt;/P&gt;&lt;P&gt;tolerance: 5,&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;snapPointSymbol: snapSym&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;} else {&lt;/P&gt;&lt;P&gt;snapKey: has("mac") ? keys.META : keys.CTRL,&lt;/P&gt;&lt;P&gt;tolerance: 5,&lt;/P&gt;&lt;P&gt;snapPointSymbol: snapSym&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;});&lt;/P&gt;&lt;P&gt;var layerInfos = [{&lt;/P&gt;&lt;P&gt;layer: lyrParcels&lt;/P&gt;&lt;P&gt;}];&lt;/P&gt;&lt;P&gt;snapManager.setLayerInfos(layerInfos);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, the syntax isn't quite right setting the snappingManagers' constructor paramters in an if else block.&amp;nbsp; Any help is appreciated.&lt;/P&gt;&lt;P&gt;Forgive the non-js highlighting on this part please - the editor syntax highlighter stopped beahving&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:03:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-help-if-else-containing-constructor-options/m-p/175553#M16314</guid>
      <dc:creator>DavidColey</dc:creator>
      <dc:date>2021-12-11T09:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax Help: If else containing constructor options</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-help-if-else-containing-constructor-options/m-p/175554#M16315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Since the isMobile is an object and not a boolean value are you sure that it is not always something besides null and thus only entering the first part of the if?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 00:00:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-help-if-else-containing-constructor-options/m-p/175554#M16315</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-03-06T00:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax Help: If else containing constructor options</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-help-if-else-containing-constructor-options/m-p/175555#M16316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Robert let me think about that . . . &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 16:45:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-help-if-else-containing-constructor-options/m-p/175555#M16316</guid>
      <dc:creator>DavidColey</dc:creator>
      <dc:date>2015-03-06T16:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax Help: If else containing constructor options</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-help-if-else-containing-constructor-options/m-p/175556#M16317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok let's see if I get this right.&amp;nbsp; Since ifMobile is an object, it should never be null unless I am not accounting for a particular OS as part of its properties, I think.&amp;nbsp; That said, I should then be able to flip the script around by invoking(?) snapManager inside of ifMobile thusly:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if (isMobile.any()){
 console.log("Mobile");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; snapManager = mapMain.enableSnapping({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alwaysSnap: true,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tolerance: 5,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; snapPointSymbol: snapSym
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
} else {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log("Not Mobile");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; snapManager = mapMain.enableSnapping({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tolerance: 5,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; snapPointSymbol: snapSym,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; snapKey: has("mac") ? keys.META : keys.CTRL
});
}&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And this seems to work pretty well, but I'll know defineitevely once I push this up so I can test on a mobile platform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks also to &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/115438"&gt;@michael&lt;/a&gt; Stranovsky&lt;/P&gt;&lt;P&gt;Thanks for your reply &lt;A href="https://community.esri.com/migrated-users/3101" target="_blank"&gt;Robert Scheitlin, GISP&lt;/A&gt;​&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:03:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-help-if-else-containing-constructor-options/m-p/175556#M16317</guid>
      <dc:creator>DavidColey</dc:creator>
      <dc:date>2021-12-11T09:03:44Z</dc:date>
    </item>
  </channel>
</rss>

