<?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: How can I save the data info and drawing to database and reopen it later? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594271#M55658</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Not only I can, other signed users will be able to open it with latitude and longitude, with information I saved before, as well as the drawing on map. This is is my goal, anybody has suggestion?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 31 Jul 2013 20:24:55 GMT</pubDate>
    <dc:creator>BillYuan</dc:creator>
    <dc:date>2013-07-31T20:24:55Z</dc:date>
    <item>
      <title>How can I save the data info and drawing to database and reopen it later?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594270#M55657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am new to this forum, did a quick search and could not find a good answer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I save the polygon on map I just draw, as well as information and reopen it later? Do I have to store it in geodatabase?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Bill&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Jul 2013 20:08:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594270#M55657</guid>
      <dc:creator>BillYuan</dc:creator>
      <dc:date>2013-07-31T20:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can I save the data info and drawing to database and reopen it later?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594271#M55658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Not only I can, other signed users will be able to open it with latitude and longitude, with information I saved before, as well as the drawing on map. This is is my goal, anybody has suggestion?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Jul 2013 20:24:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594271#M55658</guid>
      <dc:creator>BillYuan</dc:creator>
      <dc:date>2013-07-31T20:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: How can I save the data info and drawing to database and reopen it later?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594272#M55659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Welcome to the forum Bill.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Saving map info and graphics is one of the more complex concepts in web mapping with the jsapi.&amp;nbsp; It takes some serious planning, coding and testing to get it working reliably. Here's a simple overview.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There's a few ways to save map parameters like extent, and graphics. The key is json.&amp;nbsp; Many of the esri classes have a toJson method which creates a json object, which is easily saved as plain text, and which can be used to easily recreate esri class objects. Take graphics for example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's a snippet from a function that prepares map annotation (graphics) for saving.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var time = new Date().getTime().toString();

//javascript object with params for the save itself
//&amp;nbsp; and arrays for the various geometry types
var saveObj = {
&amp;nbsp; name: name,
&amp;nbsp; description: description,
&amp;nbsp; time: time,
&amp;nbsp; userId: userId,
&amp;nbsp; department, department,
&amp;nbsp; project: project,
&amp;nbsp; polygons: [],
&amp;nbsp; polylines: [],
&amp;nbsp; points: [],
&amp;nbsp; markers: [],
&amp;nbsp; text: []
};

//create json of each polygon object and push it to the polygon array
dojo.forEach(app.map.getLayer('gl_anno_polygon').graphics, function (g) {
&amp;nbsp; var obj = g.toJson();
&amp;nbsp; saveObj.polygons.push(obj)
});

//do the same polylines, points, etc

//convert js object to json
var save = dojo.toJson(saveObj);

//use ajax and some form of RDBMS to save json object

//parameters like name, userId, etc are also saved in separate fields in the database entry&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's the json of 1 polygon.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;{
&amp;nbsp; "geometry": {
&amp;nbsp;&amp;nbsp;&amp;nbsp; "rings": [[[-13715131.833534349, 5759372.32022381], [-13714845.194678271, 5759200.336910164], [-13715299.039533727, 5758751.269368976], [-13715514.018675784, 5759042.685539322], [-13715131.833534349, 5759372.32022381]]],
&amp;nbsp;&amp;nbsp;&amp;nbsp; "spatialReference": {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "wkid": 102100
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp; },
&amp;nbsp; "attributes": {
&amp;nbsp;&amp;nbsp;&amp;nbsp; "id": "1375306164892"
&amp;nbsp; },
&amp;nbsp; "symbol": {
&amp;nbsp;&amp;nbsp;&amp;nbsp; "color": [0, 115, 197, 51],
&amp;nbsp;&amp;nbsp;&amp;nbsp; "outline": {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "color": [0, 115, 197, 255],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "width": 1.5,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "type": "esriSLS",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "style": "esriSLSSolid"
&amp;nbsp;&amp;nbsp;&amp;nbsp; },
&amp;nbsp;&amp;nbsp;&amp;nbsp; "type": "esriSFS",
&amp;nbsp;&amp;nbsp;&amp;nbsp; "style": "esriSFSSolid"
&amp;nbsp; },
&amp;nbsp; "infoTemplate": {
&amp;nbsp;&amp;nbsp;&amp;nbsp; "title": "Polygon",
&amp;nbsp;&amp;nbsp;&amp;nbsp; "content": "&amp;lt;div style=\"line-height:1.5;\"&amp;gt;&amp;lt;a style=\"cursor:pointer;text-decoration:none;\" onclick=\"app.anno.editStyle(${id}, 'polygon')\"&amp;gt;Edit Polygon Style&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;a style=\"cursor:pointer;text-decoration:none;\" onclick=\"app.anno.bringTop(${id}, 'polygon')\"&amp;gt;Bring to Top&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;a style=\"cursor:pointer;text-decoration:none;\" onclick=\"app.anno.sendBottom(${id}, 'polygon')\"&amp;gt;Send to Bottom&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;a style=\"cursor:pointer;text-decoration:none;\" onclick=\"app.anno.deleteGraphic(${id}, 'polygon')\"&amp;gt;Delete&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;"
&amp;nbsp; }
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On the flip side bring graphics back in by using ajax to retrieve saves by a specific user/department and display them in a data grid for the user to load a specific save.&amp;nbsp; Here's a snippet that adds polygons back to the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;dojo.forEach(loadObj.polygons, function (polygon) {
&amp;nbsp; //the polygon param is the json for a single polygon
&amp;nbsp; //&amp;nbsp; simply creating a graphic with the json recreates it attributes, symbol and info template
&amp;nbsp; var graphic = new esri.Graphic(polygon);
&amp;nbsp; 
&amp;nbsp; //array of all loaded graphics for zooming
&amp;nbsp; features.push(graphic);
&amp;nbsp; 
&amp;nbsp; //graphic id to identify polygon to edit, delete, etc
&amp;nbsp; graphic.graphic_id = polygon.attributes.id;
&amp;nbsp; 
&amp;nbsp; //set custom objects of the graphic used by custom print task
&amp;nbsp; graphic.graphic_atts = polygon.attributes;
&amp;nbsp; graphic.graphic_it = polygon.infoTemplate;
&amp;nbsp; 
&amp;nbsp; //is the graphic a text symbol also for printing
&amp;nbsp; graphic.graphic_text = false;
&amp;nbsp; 
&amp;nbsp; //add to the annotation polygon layer
&amp;nbsp; app.map.getLayer('gl_anno_polygon').add(graphic)
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So there's some basics.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As for saving to a database.&amp;nbsp; I use php and mysql.&amp;nbsp; Super simple to set up and use. Php has great json functions that can be used for creating a json object for loading an entire applications for example.&amp;nbsp; But whatever you have and are comfortable with will work fine.&amp;nbsp; Go with a BLOB type and save yourself some hassle.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You may also try using HTML5's local storage.&amp;nbsp; I feel it's a little risky for saving graphics, but map saves, bookmarks, etc are usually ok.&amp;nbsp; If it's a business environment or folks can't risk losing data go with a database.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:31:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594272#M55659</guid>
      <dc:creator>BenFousek</dc:creator>
      <dc:date>2021-12-12T01:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can I save the data info and drawing to database and reopen it later?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594273#M55660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Great write up, Ben. Up voted. &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Jul 2013 22:04:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594273#M55660</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2013-07-31T22:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: How can I save the data info and drawing to database and reopen it later?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594274#M55661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Ben,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is just what I need to know, a wonderful summary with great knowledge in my first day!&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my plan based on your design. Envrionment: 1. Set up Arcgis server. 2. Set up a database server and a web server to host a HTML/javascript. In script,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) render map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) draw polygons with freehand, and show info template retrieving from database with key from drawing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3) Save the drawing as json text1, information as json text2, into database with a key as pair. Close the web session.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4). Reopen web session, retrieve data from database with json 1 and json 2, show map and layer, and drawing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe this would work. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Do I have to setup a custom arcgis server in production to be able to render map and save data?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Do I have to use geodatabase to store the information?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Bill&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2013 12:52:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594274#M55661</guid>
      <dc:creator>BillYuan</dc:creator>
      <dc:date>2013-08-01T12:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I save the data info and drawing to database and reopen it later?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594275#M55662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Do I have to setup a custom arcgis server in production to be able to render map and save data?&lt;BR /&gt;Do I have to use geodatabase to store the information?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can create maps without access to arcgis server.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any database will work.&amp;nbsp; You can certainly use a geodatabase with a published feature service to save data.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2013 13:53:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594275#M55662</guid>
      <dc:creator>BenFousek</dc:creator>
      <dc:date>2013-08-01T13:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can I save the data info and drawing to database and reopen it later?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594276#M55663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you! In production, I can use enterprise arcgis server, and geodatabase or RDMS to reach my goal of saving/reopen drawing and info. At a start point,&amp;nbsp; I can create map with online arcgis server and use any database to store my data,&amp;nbsp; right?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2013 16:14:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594276#M55663</guid>
      <dc:creator>BillYuan</dc:creator>
      <dc:date>2013-08-01T16:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: How can I save the data info and drawing to database and reopen it later?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594277#M55664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Ben,&lt;/P&gt;&lt;P&gt;I know its a old post but i need to do the same. I need to save the drawing (consisting of point , polygon, line , text) into database with user info&amp;nbsp; and retrieve the same when the same user log in.&lt;/P&gt;&lt;P&gt;I have just one question to the solution ..can we use feature service to store the drawings. If your ans is yes can you please provide some input for the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Dec 2015 06:51:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-save-the-data-info-and-drawing-to/m-p/594277#M55664</guid>
      <dc:creator>saurabhgupta2</dc:creator>
      <dc:date>2015-12-29T06:51:47Z</dc:date>
    </item>
  </channel>
</rss>

