Hi I have the follow routine that takes a newly made graphic and add the details to Local Storage. The idea is that it is then retrieved the next time the user uses the application
var graphic = new esri.Graphic(geometry, symbol);
console.debug(graphic)
// store to local storage graphic added
var now = new Date();
var n = now.getTime();
GraphicName = "storedGraphic" + n;
window.localStorage.setItem(GraphicName, dojo.toJson(graphic.toJson()));
console.debug(dojo.toJson(graphic.toJson()));
graphic.setAttributes({
newID: GraphicName
});
userGraphics.add(graphic);
It works fine, however I have recently given the users the ability to change outline colour.
This then fails.
Looking at my debugs - the first one (line 2 - I do like the new code format here, if nothing else
) returns
Object {geometry: Object, symbol: Object, attributes: undefined, infoTemplate: undefined, declaredClass: "esri.Graphic"â¦} - _extent: Object
- _graphicsLayer: Object
- _offsets: Array[1]
- _shape: Object
- attributes: Object
- geometry: Object
- infoTemplate: undefined
- symbol: Object
- _inherited: Object
- color: b.Color
- outline: Object
- _inherited: Object
- color: "#ff0000"
- style: "solid"
- width: "2"
- __proto__: Object
- style: "solid"
- __proto__: Object
- __proto__: Object
Notice the Colour FF0000 - basically pure red.
Now my second debug line, echoing out the JSON that I store into Local Storage
{"geometry":{"rings":[[[323189.8652275379,87282.84014002334],[326479.760210035,88064.1901983664],[327302.23395565926,84363.05834305717],[323888.9679113185,82430.24504084015],[323189.8652275379,87282.84014002334]]],"spatialReference":{"wkid":27700}},"symbol":{"color":[0,0,0,179],"outline":{"color":[null,null,null,null],"width":1.5,"type":"esriSLS","style":"esriSLSSolid"},"type":"esriSFS","style":"esriSFSSolid"}}
Look at all those nulls !
This means that the feature isn't retrieved properly, and I think may be causing issues with my print routine.
Any ideas anyone?
Cheers
ACM
Edit - yep this has a similar issue on printing - heres the Json of my print request - the same set of nulls
"featureSet": {
"geometryType": "esriGeometryPolygon",
"features": [{
"geometry": {
"rings": [
[
[310770.51166861143,
83910.69778296383
],
[314677.2619603267,
85473.39789964995
],
[315211.8698949825,
81525.52392065345
],
[313073.4381563594,
81114.28704784131
],
[310770.51166861143,
83910.69778296383
]
]
],
"spatialReference": {
"wkid": 27700
}
},
"symbol": {
"color": [0, 0, 0, 179],
"outline": {
"color": [null, null, null,
null
],
"width": 1.5,
"type": "esriSLS",
"style": "esriSLSSolid"
},
"type": "esriSFS",
"style": "esriSFSSolid"
}
}]
}