I am new to the JS 4.x language. The JS 3.x had the modes. These helped with queries where you could zoom into a FeatureLayer and have it turn on when zoomed to. The Featurelayer doesnt show up when using MODE_SELECTION until it was queried and selected. Here is an exapmple of the 3.x code:
floorOutline = new FeatureLayer (urlFloorOutline, {
mode: FeatureLayer.MODE_SELECTION,
id: 'floorOutline',
outFields: ["*"],
opacity: 0.8,
});This was added t othe map and did not show up on the map until you ran the zoom to fucntion:
function zoomFloorOutline (id)
{
require ([
"esri/tasks/query",
"esri/geometry/ScreenPoint",
"esri/geometry/Extent",
"esri/layers/FeatureLayer"
],
function (Query, ScreenPoint, Extent, FeatureLayer)
{
console.log ("zoomFloorOutline")
clearGraphics ();
var query = new Query ();
query.objectIds = [id];
var myDate = new Date ();
var myMS = myDate.getMilliseconds ();
query.where = "(" + myMS + "=" + myMS + ")";
console.log ("zoomFloorOutline + id")
floorOutline.selectFeatures (query, FeatureLayer.SELECTION_NEW, function (features)
{
var floorExtent = features[0].geometry.getExtent ().expand (1.5);
map.setExtent (floorExtent);
});
});
}
How do i do something similar with JS 4.x? I have some code to zoom to the feature but it is visible when the map is loaded and i just want show the quereied floor.
function zoomFloorOutline (id)
{
require ([
"esri/rest/query",
"esri/rest/support/Query",
"esri/layers/FeatureLayer",
"esri/views/layers/LayerView"
],
function (query, Query, FeatureLayer,LayerView)
{
console.log ("zoomFloorOutline");
// let highlight;
view.whenLayerView (floorOutline).then (function (layerView)
{
var query = floorOutline.createQuery ();
query.objectIds = [id];
query.where = "1=1";
floorOutline.queryFeatures (query).then (function (results)
{
const features = results.features;
console.log("zoom Floor" + features)
var geometry = features[0].geometry.extent.clone ().expand (2);
view.goTo (geometry);
});
});
});
}
Thanks for any help.