How to save the drawing done on the map by user ?

5026
14
Jump to solution
01-10-2012 12:04 AM
nitinsatapara
New Contributor
I am aiming to make an application in which user can do drawing...Its obvious that I will be providing some basic drawing tools like point, line, etc. For this I have used "drawing toolbar" sample code given under ArcGIS API for JavaScript. With this code there is essential functionality of drawing...

Now my question is how can I reflect this drawing made by the particular user when the same user is signing in for next time. In short, there is no code for saving this drawing. Here is what I think:

when a user project any point on the map, I ll store the latitude longitude or geographic info of that point and save it in my database. When that user signs in again, I ll draw that point with the coordinates stored in my database. So apparently user will feel that this is the drawing he/she had done previously.

I don't know I am right or wrong and If I am right then also I don't know how to implement it. So please guide me on this. If possible please provide a brief code. Let it be for implementation of a very brief feature that I am looking for, for ex. Just provide a code for storing the coordinates of a point and then redrawing it at the same location. Please do needful.

Anticipating an early favorable reply,
0 Kudos
1 Solution

Accepted Solutions
JeffPace
MVP Alum
I actually would approach this differently and does not require using the database.

I would use a cookie.

All you have to do is

1. Listen to events onGraphicAdd ,onGraphicRemove, on Dbl Click (for editing) of the GraphicsLayer
2. On event, add or remove a cookie for the graphic
i.e. dojo.cookie (graphic:1, graphic.toJson(), 1000)
3. You may also store a cookie with the number of graphics

4. On application load, just read and add the graphics back in.

View solution in original post

0 Kudos
14 Replies
RogerFrampton
New Contributor
Did you find a solution for this? I'm looking to implement something very similiar
0 Kudos
JianHuang
Occasional Contributor III
Here is some very high level steps.
You will have to host a feature service backend, which allows your users to edit features and save it to geodatabase. At the same, you need to record the username associated to the feature. Next time when he/she signs in, do a query based on the log-in user name and pull out as a JavaScript featureLayer by calling featureLayer.setDefinitionExpression("Where Clause").
Please note, writing a current log-in user name to the new created feature could be accomplished automatically by ArcGIS Server 10.1 when turning on the editor tracking function on geodatabase.
0 Kudos
nitinsatapara
New Contributor
Thanks Jian...
Your two lines of advice has made my direction of work very clear.
I never give up working on this task but it's too difficult and terrible work to do alone without guidance of anybody...
What you said in your answer is pretty much understood by me but will you please guide me for the same....with some more information...
please...I really want to dedicated my work in field of GIS...
I am sure if you will help me, I will make a magnificent application and you'll be proud of that...please help me...
0 Kudos
JeffPace
MVP Alum
I actually would approach this differently and does not require using the database.

I would use a cookie.

All you have to do is

1. Listen to events onGraphicAdd ,onGraphicRemove, on Dbl Click (for editing) of the GraphicsLayer
2. On event, add or remove a cookie for the graphic
i.e. dojo.cookie (graphic:1, graphic.toJson(), 1000)
3. You may also store a cookie with the number of graphics

4. On application load, just read and add the graphics back in.
0 Kudos
MattMoyles
New Contributor III
I actually would approach this differently and does not require using the database.

I would use a cookie.

All you have to do is

1. Listen to events onGraphicAdd ,onGraphicRemove, on Dbl Click (for editing) of the GraphicsLayer
2. On event, add or remove a cookie for the graphic
i.e. dojo.cookie (graphic:1, graphic.toJson(), 1000)
3. You may also store a cookie with the number of graphics

4. On application load, just read and add the graphics back in.


If you want to go with a non-ArcServer approach there is a more modern alternative to using a cookie. Use the HTML5 WebStorage capabilities. That is... unless you have to support some archaic monstrosity of a browser like IE8.
0 Kudos
nitinsatapara
New Contributor
I actually would approach this differently and does not require using the database.

I would use a cookie.

All you have to do is

1. Listen to events onGraphicAdd ,onGraphicRemove, on Dbl Click (for editing) of the GraphicsLayer
2. On event, add or remove a cookie for the graphic
i.e. dojo.cookie (graphic:1, graphic.toJson(), 1000)
3. You may also store a cookie with the number of graphics

4. On application load, just read and add the graphics back in.



Thanks jeff....

By providing this solution, you made my problem's solution so easy which seems too difficult to me till now...
I'll surely implement this...
0 Kudos
nitinsatapara
New Contributor
Hey guys...

The query which I put in first, I've got solution for it...means I can take points from the user at wherever he/she clicks on the map...store the points as lat long and redraw them when
user demands...

But its not about points now...Its much more....various drawings, attachments with the symbols and much important timeslider...

Thanks to all who have taken interest in this thread...I sincerely want to ask you about the implementation of timeslider...

I have studied the 4 examples provided in timeslider section of ArcGIS JavaScript API, but no modification available...I want to put my data in timesliders....

MORE IMPORTANT: I THINK TIME-SLIDER FEATURE IS NOT AVAILABLE IN WWW.ARCGIS.COM site....If it's there, do let me know how to acess it....
0 Kudos
MattMoyles
New Contributor III
Hey guys...

The query which I put in first, I've got solution for it...means I can take points from the user at wherever he/she clicks on the map...store the points as lat long and redraw them when
user demands...

But its not about points now...Its much more....various drawings, attachments with the symbols and much important timeslider...

Thanks to all who have taken interest in this thread...I sincerely want to ask you about the implementation of timeslider...

I have studied the 4 examples provided in timeslider section of ArcGIS JavaScript API, but no modification available...I want to put my data in timesliders....

MORE IMPORTANT: I THINK TIME-SLIDER FEATURE IS NOT AVAILABLE IN WWW.ARCGIS.COM site....If it's there, do let me know how to acess it....


I've been making a lot of changes myself to the stock esri time slider. Here is the code I started out with. Notice that I changed the namespace and name of the class.

I originally posted it as a fix to the bug in the TimeSlider where you cannot have more than 1 timeslider on the same page. Other than that small fix, it's vanilla.

Teh Codez iz here: http://www.pastie.org/3489637
0 Kudos
nitinsatapara
New Contributor
I've been making a lot of changes myself to the stock esri time slider. Here is the code I started out with. Notice that I changed the namespace and name of the class.

I originally posted it as a fix to the bug in the TimeSlider where you cannot have more than 1 timeslider on the same page. Other than that small fix, it's vanilla.

Teh Codez iz here: http://www.pastie.org/3489637


hats off...
I am trying to put that code in my ide....but the functionality and features that you have used put me very far behind...
thanks for your response...
0 Kudos