I have an app that is allowing the user to add a shapefile to the map. I need to test for its geometry before or after adding.
var allShapeFileLayers = [];
function addShapefileToMap (featureCollection) {
var fullExtent;
var layers = [];
arrayUtils.forEach(allShapeFileLayers, function(layer) {
app.map.removeLayer(layer);
});
arrayUtils.forEach(featureCollection.layers, function (layer) {
var infoTemplateSF = new InfoTemplate("Details", "${*}");
var featureLayerSF = new FeatureLayer(layer, {
infoTemplate: infoTemplateSF
});
featureLayerSF.on('click', function (event) {
app.map.infoWindow.setFeatures([event.graphic]);
});
changeRenderer(featureLayerSF);
fullExtent = fullExtent ?
fullExtent.union(featureLayerSF.fullExtent) : featureLayerSF.fullExtent;
layers.push(featureLayerSF);
});
allShapeFileLayers = layers;
app.map.addLayers(allShapeFileLayers);
app.map.setExtent(fullExtent.expand(1.25), true);
dom.byId('upload-status').innerHTML = "";
dojo.byId("RunQueryShapefile").style.display = "block";
// TEST FOR POLYGON ONLY
if ( allShapeFileLayers.geometry.type === "point" || allShapeFileLayers.geometry.type === "multipoint") {
alert("Point or multiPoint");
} else if ( allShapeFileLayers.geometry.type === "line" || allShapeFileLayers.geometry.type === "polyline") {
alert("Poline or polyline");
}
else {
alert("Polygon");
}
}