Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 57 additions & 25 deletions MapTour/src/app/storymaps/maptour/core/FeatureServiceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ define(["storymaps/maptour/core/TourPointAttributes",
"storymaps/maptour/core/MapTourHelper",
"esri/graphic",
"esri/geometry/Point",
"esri/geometry/Polygon",
"dojo/topic"],
function (
TourPointAttributes,
MapTourHelper,
Graphic,
Point,
Polygon,
topic
) {
return function FeatureServiceManager()
Expand All @@ -31,16 +33,29 @@ define(["storymaps/maptour/core/TourPointAttributes",
if( isFSWithURLFields || ! featureLayer.hasAttachments ) {
for (i = 0; i < featureLayer.graphics.length; i++) {
var feature = featureLayer.graphics[i];
var graphic = new Graphic(
new Point(
feature.geometry.x,
feature.geometry.y,
feature.geometry.spatialReference
),
null,
new TourPointAttributes(feature)
);
graphics.push(graphic);
//added code here to support point & polygon
if(feature.geometry.type == "point") {
var graphic = new Graphic(
new Point(
feature.geometry.x,
feature.geometry.y,
feature.geometry.spatialReference
),
null,
new TourPointAttributes(feature)
);
graphics.push(graphic);
}
else if(feature.geometry.type == "polygon") {
//get the centroid when the feature is polygon
var graphic = new Graphic(
new Point( feature.geometry.getCentroid() ),
null,
new TourPointAttributes(feature)
);
graphics.push(graphic);
}
// graphics.push(graphic);
}
publishCompleteEvent();
}
Expand Down Expand Up @@ -80,21 +95,38 @@ define(["storymaps/maptour/core/TourPointAttributes",

// Check the type of attachment
if( MapTourHelper.isSupportedImgExt(pict.name) && MapTourHelper.isSupportedImgExt(thumb.name) ) {
var graphic = new Graphic(
new Point(
feature.geometry.x,
feature.geometry.y,
feature.geometry.spatialReference
),
null,
new TourPointAttributes(
feature,
pict.url,
thumb.url
)
);
//added code here to support point & polygon
if(feature.geometry.type == "point") {
var graphic = new Graphic(
new Point(
feature.geometry.x,
feature.geometry.y,
feature.geometry.spatialReference
),
null,
new TourPointAttributes(
feature,
pict.url,
thumb.url
)
);
graphics.push(graphic);
}
else if(feature.geometry.type == "polygon") {
//get the centroid when the feature is polygon
var graphic = new Graphic(
new Point( feature.geometry.getCentroid() ),
null,
new TourPointAttributes(
feature,
pict.url,
thumb.url
)
);
graphics.push(graphic);
}

graphics.push(graphic);
// graphics.push(graphic);
}
}

Expand All @@ -119,4 +151,4 @@ define(["storymaps/maptour/core/TourPointAttributes",
}
};
}
);
);
32 changes: 24 additions & 8 deletions MapTour/src/app/storymaps/maptour/core/MainView.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ define(["storymaps/maptour/core/WebApplicationData",
"esri/renderers/UniqueValueRenderer",
"esri/graphic",
"esri/geometry/Point",
"esri/geometry/Polygon",
"esri/geometry/Extent",
"esri/config",
"esri/geometry/webMercatorUtils",
Expand Down Expand Up @@ -49,6 +50,7 @@ define(["storymaps/maptour/core/WebApplicationData",
UniqueValueRenderer,
Graphic,
Point,
Polygon,
Extent,
esriConfig,
webMercatorUtils,
Expand Down Expand Up @@ -280,7 +282,9 @@ define(["storymaps/maptour/core/WebApplicationData",
layerId = layerId.split('_').slice(0,1).join('_');

// Exclude map notes and not point layers
if( layerId.match(/^mapNotes_/) || layer.geometryType != "esriGeometryPoint" )
// changed code to support Polygon
// if( layerId.match(/^mapNotes_/) || layer.geometryType != "esriGeometryPoint" )
if( layerId.match(/^mapNotes_/) || (layer.geometryType != "esriGeometryPoint" && layer.geometryType != "esriGeometryPolygon") )
continue;

// Loop through webmap layers to see if title match
Expand All @@ -302,9 +306,11 @@ define(["storymaps/maptour/core/WebApplicationData",
layer = app.map._layers[layerName];

// Catch visible FS and webmap embedded point layers
// added code to support Polygon
if( (layer.visible || layer.visible === undefined)
&& (layer.type == "Feature Layer" || layer._collection)
&& layer.geometryType == "esriGeometryPoint"
&& (layer.geometryType == "esriGeometryPoint" || layer.geometryType == "esriGeometryPolygon")
// && layer.geometryType == "esriGeometryPoint"
&& ! layerName.match(/^mapNotes_/) )
{
// If it's a webmap layer check that all mandatory fields are present to allow additional decoration layer
Expand Down Expand Up @@ -413,11 +419,21 @@ define(["storymaps/maptour/core/WebApplicationData",

var graphics = [];
$(app.data.getSourceLayer().graphics).each(function(i, graphic) {
graphics.push(new Graphic(
new Point(graphic.geometry.x, graphic.geometry.y, graphic.geometry.spatialReference),
null,
new TourPointAttributes(graphic, null, null, true)
));
//added code here to support point & polygon (in case csv may contain polygon info)
if(graphic.geometry.type == "point") {
graphics.push(new Graphic(
new Point(graphic.geometry.x, graphic.geometry.y, graphic.geometry.spatialReference),
null,
new TourPointAttributes(graphic, null, null, true)
));
}
else if(graphic.geometry.type == "polygon") {
graphics.push(new Graphic(
new Point(graphic.geometry.getCentroid()),
null,
new TourPointAttributes(graphic, null, null, true)
));
}
});

tourPointLayerLoaded({ graphics: graphics });
Expand Down Expand Up @@ -1492,4 +1508,4 @@ define(["storymaps/maptour/core/WebApplicationData",
};
};
}
);
);
13 changes: 11 additions & 2 deletions MapTour/src/app/storymaps/maptour/core/TourData.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ define(["storymaps/maptour/core/WebApplicationData",
"esri/layers/FeatureLayer",
"esri/graphic",
"esri/geometry/Point",
"esri/geometry/Polygon",
"dojo/topic"],
function(
WebApplicationData,
Expand All @@ -20,6 +21,7 @@ define(["storymaps/maptour/core/WebApplicationData",
FeatureLayer,
Graphic,
Point,
Polygon,
topic
){
/**
Expand Down Expand Up @@ -532,7 +534,14 @@ define(["storymaps/maptour/core/WebApplicationData",
var nbPointsBeforeImport = this.getTourPoints(false).length;

$.each(featureCollection.featureSet.features, function(i, feature){
addTourPointUsingAttributes(new Point(feature.geometry), feature.attributes);
//added code here to support point & polygon
if(feature.geometry.type == "point") {
addTourPointUsingAttributes(new Point(feature.geometry), feature.attributes);
}
else if(feature.geometry.type == "polygon") {
addTourPointUsingAttributes(new Point(feature.geometry.getCentroid()), feature.attributes);
}
// addTourPointUsingAttributes(new Point(feature.geometry), feature.attributes);
});

processPointsOrder( computeTourPointOrderFromConfig() );
Expand Down Expand Up @@ -1208,4 +1217,4 @@ define(["storymaps/maptour/core/WebApplicationData",
};
};
}
);
);