<?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: Can't create Graphic using a CartographicLineSymbol json symbol. in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63610#M5567</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Are the spatial reference objects being generated correctly?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you recreate the issue using &lt;/SPAN&gt;&lt;A href="http://jsfiddle.net"&gt;http://jsfiddle.net&lt;/A&gt;&lt;SPAN&gt; so I can take a look?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Jan 2014 15:27:08 GMT</pubDate>
    <dc:creator>JonathanUihlein</dc:creator>
    <dc:date>2014-01-21T15:27:08Z</dc:date>
    <item>
      <title>Can't create Graphic using a CartographicLineSymbol json symbol.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63608#M5565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using 3.8. Creating a drawing tool and I'm storing the "toJson()" results in the database. Everything works fine for points and polygons. I can recreate them by simply calling new.Graphic(json); Here is the issue,??? Line symbols or CartographicLineSymbol symbols will not recreate from json. The graphic object gets created with all the attributes and geometry but symbol = null. Has anybody else experience this? Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jan 2014 10:39:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63608#M5565</guid>
      <dc:creator>PatrickTruitt</dc:creator>
      <dc:date>2014-01-21T10:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: Can't create Graphic using a CartographicLineSymbol json symbol.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63609#M5566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To add more to this weird issue is the fact that I can get a CartographicLine symbol to create from json only if I create it as a SimpleLineSymbol. But If create a SimpleLineSymbol json object and try to create a simpleLineSymbol from that json, it doesn't work. This has to be a Esri bug.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jan 2014 11:47:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63609#M5566</guid>
      <dc:creator>PatrickTruitt</dc:creator>
      <dc:date>2014-01-21T11:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Can't create Graphic using a CartographicLineSymbol json symbol.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63610#M5567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Are the spatial reference objects being generated correctly?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you recreate the issue using &lt;/SPAN&gt;&lt;A href="http://jsfiddle.net"&gt;http://jsfiddle.net&lt;/A&gt;&lt;SPAN&gt; so I can take a look?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jan 2014 15:27:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63610#M5567</guid>
      <dc:creator>JonathanUihlein</dc:creator>
      <dc:date>2014-01-21T15:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: Can't create Graphic using a CartographicLineSymbol json symbol.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63611#M5568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is a sample&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://jsfiddle.net/phoxoey/tcLtq/11/"&gt;http://jsfiddle.net/phoxoey/tcLtq/11/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the setSymbolType() function, if you switch from creating a Cartographic to creating a SimpleLine,.. it will work but by default, creating a Graphic from a Cartographic json object will not work. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for look at this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jan 2014 12:45:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63611#M5568</guid>
      <dc:creator>PatrickTruitt</dc:creator>
      <dc:date>2014-01-22T12:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can't create Graphic using a CartographicLineSymbol json symbol.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63612#M5569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Patrick!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Took a quick look and it seems your symbol object is getting distorted when using toJson().&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You will want to recreate the symbol object in code from your db values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would also use a polyline. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's your addAnnoLineHandler() function slightly redone:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

function addAnnoLineHandler(evt) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; tb.deactivate();
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.enableMapNavigation();

&amp;nbsp;&amp;nbsp;&amp;nbsp; var symbol = new esri.symbol.CartographicLineSymbol(esri.symbol.CartographicLineSymbol.STYLE_SOLID,new dojo.Color("#000000"),2,esri.symbol.CartographicLineSymbol.CAP_ROUND,esri.symbol.CartographicLineSymbol.JOIN_MITER,1);
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var baseGraphic = new esri.Graphic( evt, annotationSymbol );
&amp;nbsp;&amp;nbsp;&amp;nbsp; //map.graphics.add(baseGraphic); // adds graphic directly to map
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var baseGraphicJson = baseGraphic.toJson();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var polyline = new esri.geometry.Polyline( baseGraphicJson.geometry ); // note use of geometry property
&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log( 'polyline', polyline );
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var graphicFromDB = new esri.Graphic( polyline, symbol );
&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log( 'graphicFromDB', graphicFromDB );

&amp;nbsp;&amp;nbsp;&amp;nbsp; gLayer.add( graphicFromDB );
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NOTE:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you end up using:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;tb.on("draw-complete", addAnnoLineHandler);&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;over&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;dojo.connect(tb, "onDrawEnd", addAnnoLineHandler);&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;... you will need to change addAnnoLineHandler() to accommodate, as 'evt' will no longer be what you expect.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:26:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63612#M5569</guid>
      <dc:creator>JonathanUihlein</dc:creator>
      <dc:date>2021-12-10T22:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Can't create Graphic using a CartographicLineSymbol json symbol.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63613#M5570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the reply. I understand your response but this solution won't work for me. I need to understand why toJson() works for some symbols but not others. More important, why it does't work for line symbols. If toJson works perfectly for point and polygon symbols why would I expect a different outcome for the other remaining symbols with the same toJson function?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jan 2014 16:44:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63613#M5570</guid>
      <dc:creator>PatrickTruitt</dc:creator>
      <dc:date>2014-01-22T16:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: Can't create Graphic using a CartographicLineSymbol json symbol.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63614#M5571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Some objects cannot be recreated from json if certain construction params are not successfully saved in the json representation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You will want to recreate the symbol object in code from your db values.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe you wanted to create your symbols from your db info correct? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You needed to change my code slightly. See below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function addAnnoLineHandler(evt) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; tb.deactivate();
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.enableMapNavigation();

&amp;nbsp;&amp;nbsp;&amp;nbsp; var baseGraphic = new esri.Graphic( evt, annotationSymbol );
&amp;nbsp;&amp;nbsp;&amp;nbsp; //map.graphics.add(baseGraphic); // adds graphic directly to map
&amp;nbsp;&amp;nbsp;&amp;nbsp; var baseGraphicJson = baseGraphic.toJson();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var symbol = new esri.symbol.CartographicLineSymbol( baseGraphicJson.symbol );
&amp;nbsp;&amp;nbsp;&amp;nbsp; var polyline = new esri.geometry.Polyline( baseGraphicJson.geometry );
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var graphicFromDB = new esri.Graphic( polyline, symbol );

&amp;nbsp;&amp;nbsp;&amp;nbsp; gLayer.add( graphicFromDB );
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This worked for me. Why does this not work for you? Please be as specific as possible. Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:26:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63614#M5571</guid>
      <dc:creator>JonathanUihlein</dc:creator>
      <dc:date>2021-12-10T22:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Can't create Graphic using a CartographicLineSymbol json symbol.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63615#M5572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is fine within the specific handler for each symbol because I know that the user is creating a point or a line. The problem is when the user opens the application and it fetches the annotations from the database. I didn't want to have to parse each type in order create the correct symbol and geometry separately. I just want to call Graphic(json) where json has all this information already per the API documentation.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jan 2014 17:55:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-t-create-graphic-using-a/m-p/63615#M5572</guid>
      <dc:creator>PatrickTruitt</dc:creator>
      <dc:date>2014-01-22T17:55:21Z</dc:date>
    </item>
  </channel>
</rss>

