<?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: CenterAt not working in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/centerat-not-working/m-p/61190#M5389</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That's what I get for posting without testing...my bad.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What is your map's spatial reference?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can confirm that centerAt works by going to this sample:&amp;nbsp; &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/samples/map_topo/index.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/samples/map_topo/index.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then entering this in the console:&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var coordinates = prompt("Enter coordinates: ", "-13600000,4545000").split(",");
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Press OK. Then enter this to center the map:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
map.centerAt(new esri.geometry.Point(coordinates[0], coordinates[1], map.spatialReference));
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Or...&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
map.centerAt(new esri.geometry.Point({ "x": coordinates[0], "y": coordinates[1], "spatialReference": map.spatialReference}));
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 22:19:56 GMT</pubDate>
    <dc:creator>derekswingley1</dc:creator>
    <dc:date>2021-12-10T22:19:56Z</dc:date>
    <item>
      <title>CenterAt not working</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/centerat-not-working/m-p/61187#M5386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I signed up to ask this question: Does CenterAt work? And if so, what am I doing wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've created a simple function to move to some coordinates:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; this.goto = function () { &amp;nbsp;&amp;nbsp;&amp;nbsp; var coordinates = prompt("Enter coordinates: ", "502982,221818").split(","); &amp;nbsp;&amp;nbsp;&amp;nbsp; if (coordinates.length != 2) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return; &amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp; var point = new esri.geometry.Point({ "x": coordinates[0], "y": coordinates[1], " spatialReference": { " wkid": 27700} }); &amp;nbsp;&amp;nbsp;&amp;nbsp; self.map.centerAt(point); &amp;nbsp;&amp;nbsp;&amp;nbsp; self.map.setLevel(10);&amp;nbsp; }&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, only the setLevel seems to happen. I am never centered to the new results.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 10:33:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/centerat-not-working/m-p/61187#M5386</guid>
      <dc:creator>TimMcCurdy</dc:creator>
      <dc:date>2012-10-25T10:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: CenterAt not working</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/centerat-not-working/m-p/61188#M5387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/point.htm#PointConst3" rel="nofollow noopener noreferrer" target="_blank"&gt;x and y properties of the object&lt;/A&gt;&lt;SPAN&gt; passed to the point constructor need to be numbers. Try converting to numbers with parseInt:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var point = new esri.geometry.Point({ "x": parseInt(coordinates[0]), "y": parseInt(coordinates[1]), " spatialReference": { " wkid": 27700} });
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:19:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/centerat-not-working/m-p/61188#M5387</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2021-12-10T22:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: CenterAt not working</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/centerat-not-working/m-p/61189#M5388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The &lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/point.htm#PointConst3" rel="nofollow noopener noreferrer" target="_blank"&gt;x and y properties of the object&lt;/A&gt; passed to the point constructor need to be numbers. Try converting to numbers with parseInt:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var point = new esri.geometry.Point({ "x": parseInt(coordinates[0]), "y": parseInt(coordinates[1]), " spatialReference": { " wkid": 27700} });
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This did not resolve the issue, and I'm not sure why it would since its a JSON object.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just to be sure, I changed to standard parameters and this did not work either:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var point = new esri.geometry.Point(parseInt(coordinates[0]), parseInt(coordinates[1]), new esri.SpatialReference({ wkid: 27700 }));
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:19:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/centerat-not-working/m-p/61189#M5388</guid>
      <dc:creator>TimMcCurdy</dc:creator>
      <dc:date>2021-12-10T22:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: CenterAt not working</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/centerat-not-working/m-p/61190#M5389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That's what I get for posting without testing...my bad.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What is your map's spatial reference?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can confirm that centerAt works by going to this sample:&amp;nbsp; &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/samples/map_topo/index.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/samples/map_topo/index.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then entering this in the console:&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var coordinates = prompt("Enter coordinates: ", "-13600000,4545000").split(",");
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Press OK. Then enter this to center the map:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
map.centerAt(new esri.geometry.Point(coordinates[0], coordinates[1], map.spatialReference));
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Or...&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
map.centerAt(new esri.geometry.Point({ "x": coordinates[0], "y": coordinates[1], "spatialReference": map.spatialReference}));
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:19:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/centerat-not-working/m-p/61190#M5389</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2021-12-10T22:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: CenterAt not working</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/centerat-not-working/m-p/61191#M5390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using that code on that page seems to work, something must be wrong with my mapping setup I suppose.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I swapped to using self.map.spacialReference instead of creating a new one, but this has not helped.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, I tried carrying out similar commands in the console, and for some reason it works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var coordinates = prompt("Enter coordinates: ", "502982,221818").split(","); var mapControl = Symology.MapMgr.getControl('984604c6-0bd2-4ba5-a990-aa9d6675d1ed'); mapControl.map.centerAt(new esri.geometry.Point(coordinates[0], coordinates[1], mapControl.map.spatialReference));&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was a bit suspicious, so I removed the line that setLevel(10), and now my original code works. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Swaping around the commands, so setLevel THEN centerAt, seems to work. However my original, centerAt THEN setLevel seems to override the centerAt command.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Oct 2012 07:59:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/centerat-not-working/m-p/61191#M5390</guid>
      <dc:creator>TimMcCurdy</dc:creator>
      <dc:date>2012-10-26T07:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: CenterAt not working</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/centerat-not-working/m-p/61192#M5391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;i think this is do to javascript being asynchronous.&amp;nbsp; centerat fires (but does not complete), so when setlevel fires the map center is still the old one.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;centerat then completes, and then setlevel does.&amp;nbsp; So the final command is setlevel using the original center.&amp;nbsp; Hence it looks like centerat never fired&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;have you tried the centerAndZoom method?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/map.htm#centerAndZoom"&gt;http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/map.htm#centerAndZoom&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Oct 2012 18:56:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/centerat-not-working/m-p/61192#M5391</guid>
      <dc:creator>JeffPace</dc:creator>
      <dc:date>2012-10-26T18:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: CenterAt not working</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/centerat-not-working/m-p/61193#M5392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;i think this is do to javascript being asynchronous.&amp;nbsp; centerat fires (but does not complete), so when setlevel fires the map center is still the old one.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;centerat then completes, and then setlevel does.&amp;nbsp; So the final command is setlevel using the original center.&amp;nbsp; Hence it looks like centerat never fired&lt;BR /&gt;&lt;BR /&gt;have you tried the centerAndZoom method?&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/map.htm#centerAndZoom"&gt;http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/map.htm#centerAndZoom&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using a dynamic service in this instance, so zooming by a factor is not what I want.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for the help in this though, I don't need any more assistance now that I realise I just had to swap my commands around.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Oct 2012 10:49:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/centerat-not-working/m-p/61193#M5392</guid>
      <dc:creator>TimMcCurdy</dc:creator>
      <dc:date>2012-10-29T10:49:24Z</dc:date>
    </item>
  </channel>
</rss>

