Sample Usage - adamjpfister/drag-drop-map-js GitHub Wiki
//create a map
var map = new Map({ ... });
var ddm = new DragDropMap({
map: map,
csv: {
pointSymbol: new SimpleMarkerSymbol().setColor(new Color('red')).setSize(8),
returnGraphicsExtent: true,
xyFields: ['EXCEL_POINT_X', 'EXCEL_POINT_Y']
},
image: {
maxImageSize: [32,32]
},
featureService: {
allOutFields: false
},
agsRestQuery: {
returnGraphicsExtent: true
}
});
//listen for the drop process complete event and then dominate when it's ready
ddm.on('drop-process-complete',
function (result) {
var dropType = result.dropType;
if (dropType === 'csv' || dropType === 'agsRestQuery') {
array.forEach(result.graphics,
function(graphic) {
map.graphics.add(graphic);
if (result.graphicsExtent)
map.setExtent(result.graphicsExtent, true);
}
);
} else if (dropType === 'image') {
map.graphics.add(result.graphic);
} else {
//either a map, feature or image layer is the result
map.addLayer(result.layer);
}
}
);
ddm.on('drop-process-error', function (error) {
console.log(error);
});