I need to add graphics to a map with class.
Is it any sample or way to save it to IndexedDB or Local Storage ?
I tried to use offline-editor-js but this library don´t offer possibility to save graphics.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityI need to add graphics to a map with class.
Is it any sample or way to save it to IndexedDB or Local Storage ?
I tried to use offline-editor-js but this library don´t offer possibility to save graphics.
require([
"esri/map",
"esri/toolbars/draw",
"esri/layers/GraphicsLayer",
"esri/symbols/SimpleFillSymbol",
"esri/graphic",
"dojo/domReady!"
], function(
Map, Draw,
GraphicsLayer, SimpleFillSymbol,
Graphic
) {
map = new Map("mapDiv", {
basemap: "streets",
center: [-25.312, 34.307],
zoom: 3
});
var tempLayer = new GraphicsLayer();
map.addLayer(tempLayer)
if(localStorage.features != undefined){
JSON.parse(localStorage.features).forEach(function(featureJson){
tempLayer.add(new Graphic(featureJson));
})
}
var tool = new Draw(map);
tool.on("draw-end",function(evt){
var graphic= new Graphic(evt.geometry,new SimpleFillSymbol());
tempLayer.add(graphic)
var graphics =[];
if(localStorage.features != undefined){
graphics = JSON.parse(localStorage.features)
}
graphics.push(graphic.toJson());
localStorage.features=JSON.stringify(graphics);
})
tool.activate(Draw.POLYGON)
});