<?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: map.graphics is null (and likely related 'this._gc.surface' is null ) in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-graphics-is-null-and-likely-related-this-gc/m-p/141968#M13221</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: mliebster&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;wish you would have posted the solution... I've been battling this one for over a week! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My bad - I should have done so.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There weren't many views on the thread and it had no replies, so I assumed I was doing something so stupid and unique to myself.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Jan 2011 15:36:03 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2011-01-17T15:36:03Z</dc:date>
    <item>
      <title>map.graphics is null (and likely related 'this._gc.surface' is null )</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-graphics-is-null-and-likely-related-this-gc/m-p/141964#M13217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've been able to display a map just fine. However I am having problems adding a graphic to it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I first tried to just to do a map.graphics.add() and the graphics object is null (see graphic-null.jpg).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So to work around that I tried to create a graphics layer and then add the graphic to that, but got an error about the _gc.surface being null when trying to add the layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The maps show up just fine when I don't try to add them. A breakpoint in the js shows that it's getting the homePoint values. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've looked through various samples to see that my code is the same and I don't see a difference. But I'm sure I'm missing something, as those work and mine doesn't.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In ASP.MVC code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/tundra/tundra.css" /&amp;gt;
&amp;lt;script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;script type="text/javascript"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; var homePoint = new esri.geometry.Point(@Model.Data.HomeLon, @Model.Data.HomeLat);&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my js file (kept seperate for SoC preference)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var hMap;

dojo.require("esri.map");
dojo.require("esri.layers.graphics");
dojo.addOnLoad(initMaps);

function initMaps() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; homeExtent = new esri.geometry.Extent(homePoint.x - 0.5,
&amp;nbsp;&amp;nbsp;&amp;nbsp; homePoint.y - 0.5,
&amp;nbsp;&amp;nbsp;&amp;nbsp; homePoint.x + 0.5,
&amp;nbsp;&amp;nbsp;&amp;nbsp; homePoint.y + 0.5);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; hMap = new esri.Map("homeMap", { extent: homeExtent, logo: false });
&amp;nbsp;&amp;nbsp;&amp;nbsp; var basemapURL = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
&amp;nbsp;&amp;nbsp;&amp;nbsp; var basemap = new esri.layers.ArcGISTiledMapServiceLayer(basemapURL);
&amp;nbsp;&amp;nbsp;&amp;nbsp; hMap.addLayer(basemap);
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the help!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:49:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-graphics-is-null-and-likely-related-this-gc/m-p/141964#M13217</guid>
      <dc:creator>MartenLiebster</dc:creator>
      <dc:date>2021-12-11T07:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: map.graphics is null (and likely related 'this._gc.surface' is null )</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-graphics-is-null-and-likely-related-this-gc/m-p/141965#M13218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was getting the same Jscript runtime error: "this._gc._surface" is null or not an object when adding a new graphics layer to the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I found the solution here: &lt;/SPAN&gt;&lt;A href="http://forums.esri.com/Thread.asp?c=93&amp;amp;f=2396&amp;amp;t=284131&amp;amp;g=1" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.esri.com/Thread.asp?c=93&amp;amp;f=2396&amp;amp;t=284131&amp;amp;g=1&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The solution was to not load the graphics layer until after the map is finished loading.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
selLayer = new esri.layers.GraphicsLayer();

dojo.connect(map, "onLoad", function() {
&amp;nbsp;&amp;nbsp; map.addLayer(selLayer));
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not sure if you are trying to add your graphics to a new graphics layer or the default graphics layer maps.graphics&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but this solution worked for me.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:49:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-graphics-is-null-and-likely-related-this-gc/m-p/141965#M13218</guid>
      <dc:creator>Kathleen_Crombez</dc:creator>
      <dc:date>2021-12-11T07:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: map.graphics is null (and likely related 'this._gc.surface' is null )</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-graphics-is-null-and-likely-related-this-gc/m-p/141966#M13219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: mliebster&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I got it working doing just that! I just neglected to post the solution.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jan 2011 15:02:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-graphics-is-null-and-likely-related-this-gc/m-p/141966#M13219</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2011-01-17T15:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: map.graphics is null (and likely related 'this._gc.surface' is null )</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-graphics-is-null-and-likely-related-this-gc/m-p/141967#M13220</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;wish you would have posted the solution... I've been battling this one for over a week! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jan 2011 15:32:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-graphics-is-null-and-likely-related-this-gc/m-p/141967#M13220</guid>
      <dc:creator>Kathleen_Crombez</dc:creator>
      <dc:date>2011-01-17T15:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: map.graphics is null (and likely related 'this._gc.surface' is null )</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-graphics-is-null-and-likely-related-this-gc/m-p/141968#M13221</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: mliebster&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;wish you would have posted the solution... I've been battling this one for over a week! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My bad - I should have done so.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There weren't many views on the thread and it had no replies, so I assumed I was doing something so stupid and unique to myself.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jan 2011 15:36:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-graphics-is-null-and-likely-related-this-gc/m-p/141968#M13221</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2011-01-17T15:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: map.graphics is null (and likely related 'this._gc.surface' is null )</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-graphics-is-null-and-likely-related-this-gc/m-p/141969#M13222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I was getting the same Jscript runtime error: "this._gc._surface" is null or not an object when adding a new graphics layer to the map.&lt;BR /&gt;&lt;BR /&gt;I found the solution here: &lt;A href="http://forums.esri.com/Thread.asp?c=93&amp;amp;f=2396&amp;amp;t=284131&amp;amp;g=1" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.esri.com/Thread.asp?c=93&amp;amp;f=2396&amp;amp;t=284131&amp;amp;g=1&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;The solution was to not load the graphics layer until after the map is finished loading.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
selLayer = new esri.layers.GraphicsLayer();

dojo.connect(map, "onLoad", function() {
&amp;nbsp;&amp;nbsp; map.addLayer(selLayer));
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Not sure if you are trying to add your graphics to a new graphics layer or the default graphics layer maps.graphics&lt;BR /&gt;&lt;BR /&gt;but this solution worked for me.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If you choose this solution, then you have to add your graphics to the selLayer, and not to the default map.graphics layer. Apart from that, it works fine.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:49:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-graphics-is-null-and-likely-related-this-gc/m-p/141969#M13222</guid>
      <dc:creator>AndreasHoogeveen</dc:creator>
      <dc:date>2021-12-11T07:49:13Z</dc:date>
    </item>
  </channel>
</rss>

