Retour à la documentation
define(
['dojo/_base/declare', 'esri/layers/GraphicsLayer', 'dojo/_base/lang', 'dojo/_base/array', 'esri/graphic',
'spw/api/ProjectionManager', 'spw/api/DataLayer'],
function(declare, GraphicsLayer, lang, array, Graphic, ProjectionManager, DataLayer) {
/**
* @class spw.api.SpwGraphicsLayer
* @classdesc Service sur lequel ajouter des dessins
* @extends {esri/layers/GraphicsLayer}
*/
return declare("spw.api.SpwGraphicsLayer", [DataLayer], /**@lends spw.api.SpwGraphicsLayer.prototype */{
//START : options
// _options: null,
/**
* @constructs
*/
// constructor: function(options) {
// pour ne pas que la lib esri modifie l'id du layer automatiquement...
// if (options.graphics) {
// this.jsonToGraphics(options.graphics, options.spwMap);
// delete options.graphics;
// }
// this._options = options;
// lang.mixin(this, options);
// },
// /**
// * Ajoute des données representées en JSON sur le service
// * @param graphics les données à ajouter au format JSON
// * @param spwMap la référence à SpwMap
// */
// jsonToGraphics: function(graphics, spwMap) {
// this.clear();
//
// spwMap = spwMap || this.spwMap;
//
// var data = JSON.parse(graphics);
//
// var viewerSrid = spwMap.getSpatialReferenceSRID();
//
// array.forEach(data, lang.hitch(this, function(d) {
// var g = new Graphic(d);
//
// if (g.geometry.spatialReference.wkid !== viewerSrid) {
// g.geometry = ProjectionManager.getInstance().transform(g.geometry.spatialReference.wkid, viewerSrid, g.geometry);
// }
//
// this.add(g);
//
// if (d._buffers) {
// g._buffers = array.map(d._buffers, lang.hitch(this, function(buf) {
// var tmp = new Graphic(buf);
//
// if (tmp.geometry.spatialReference.wkid !== viewerSrid) {
// tmp.geometry = ProjectionManager.getInstance().transform(tmp.geometry.spatialReference.wkid, viewerSrid, tmp.geometry);
// }
//
// if (buf.associatedMesure) {
// tmp.associatedMesure = new Graphic(buf.associatedMesure);
// tmp.associatedMesure.associatedGraphic = tmp;
//
// if (tmp.associatedMesure.geometry.spatialReference.wkid !== viewerSrid) {
// tmp.associatedMesure.geometry = ProjectionManager.getInstance().transform(tmp.associatedMesure.geometry.spatialReference.wkid, viewerSrid, tmp.associatedMesure.geometry);
// }
//
// this.add(tmp.associatedMesure);
// }
//
// tmp._buffer = g;
// this.add(tmp);
// return tmp;
// }));
//
// g._bufferValue = d._bufferValue;
// g._repetitionValue = d._repetitionValue;
// g._bufferLabels = d._bufferLabels;
// }
//
// if (d._coordinates) {
// g._coordinates = new Graphic(d._coordinates);
// g._coordinates.associatedGraphic = g;
//
// if (g._coordinates.geometry.spatialReference.wkid !== viewerSrid) {
// g._coordinates.geometry = ProjectionManager.getInstance().transform(g._coordinates.geometry.spatialReference.wkid, viewerSrid, g._coordinates.geometry);
// }
//
// this.add(g._coordinates);
// }
//
// if (d.associatedMesure) {
// g.associatedMesure = new Graphic(d.associatedMesure);
// g.associatedMesure.associatedGraphic = g;
// g.associatedMesure.selectedValue = d.selectedMesureValue;
//
// if (g.associatedMesure.geometry.spatialReference.wkid !== viewerSrid) {
// g.associatedMesure.geometry = ProjectionManager.getInstance().transform(g.associatedMesure.geometry.spatialReference.wkid, viewerSrid, g.associatedMesure.geometry);
// }
//
// this.add(g.associatedMesure);
// }
//
// if (d.associatedArea) {
// g.associatedArea = new Graphic(d.associatedArea);
// g.associatedArea.associatedGraphic = g;
// g.associatedArea.selectedValue = d.selectedAreaValue;
//
// if (g.associatedArea.geometry.spatialReference.wkid !== viewerSrid) {
// g.associatedArea.geometry = ProjectionManager.getInstance().transform(g.associatedArea.geometry.spatialReference.wkid, viewerSrid, g.associatedArea.geometry);
// }
//
// this.add(g.associatedArea);
// }
// }));
// },
//
// /**
// * Convertir les données du service au format JSON
// * @return les données au format JSON
// */
// graphicsToJson: function() {
// var data = [];
// array.forEach(this.graphics, lang.hitch(this, function(g) {
// if (g._buffer) {
// return;
// }
//
// if (g.associatedGraphic) {
// return;
// }
//
// var json = g.toJson();
//
// if (g._buffers) {
// lang.mixin(json, {
// _buffers: array.map(g._buffers, function(buf) {
// var tmp = buf.toJson();
//
// if (buf.associatedMesure) {
// tmp.associatedMesure = buf.associatedMesure.toJson();
// }
//
// return tmp;
// }),
// _bufferValue: g._bufferValue,
// _repetitionValue: g._repetitionValue,
// _bufferLabels: g._bufferLabels
// });
// }
//
// if (g._coordinates) {
// lang.mixin(json, {
// _coordinates: g._coordinates.toJson()
// });
// }
//
// if (g.associatedMesure) {
// lang.mixin(json, {
// associatedMesure: g.associatedMesure.toJson(),
// selectedMesureValue: g.associatedMesure.selectedValue
// });
// }
//
// if (g.associatedArea) {
// lang.mixin(json, {
// associatedArea: g.associatedArea.toJson(),
// selectedAreaValue: g.associatedArea.selectedValue
// });
// }
//
// data.push(json);
// }));
// return JSON.stringify(data);
// }
});
}
);