GoTo some extent when featureset is empty

155
2
12-06-2019 09:41 AM
GregoryBologna
Occasional Contributor

How do I get a default or initial extent from my ArcGIS without hard-coding it? For example, whenever a FeatureSet is not populated after executing a QueryTask, the mapview goes to the middle of the ocean instead of somewhere in my map area. If I can get the extent then I could zoom to it.

if (featureSet.features && !featureSet.features.length > 0) {
   view.goTo({
        target: view.extent
    }, ZoomOptions);
}

The returned extent from the zero results query doesn't have a valid extent, obviously.

type:"extent"
width:0
xmax:0
xmin:0
ymax:9688.393335133032
ymin:-9688.393335133032
zmax:undefined
zmin:undefined

I want the exent from here

https://gis.manateepao.com/arcgis/rest/services/Website/WebLayers/MapServer/256 

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Gregory,

   The extent used in the goTo method has to have the same spatial reference as the map view does. So you would need to re-project that extent info before you use it in the goTo method.

0 Kudos
GregoryBologna
Occasional Contributor

Thanks. Setting the initial long\lat to specific location when a featureset is not found is working out for me.

var view = new MapView({
map: map,
center: [-82.414233, 27.491344]

0 Kudos