I need to have the same spatial reference between the MapView and my feature layer because I am performing a queryTask and then using the popup to zoom to the feature. The query result feature is in State Plane, and the Map and MapView are in Web Mercator because I am using an esri basemap. The zoom to in the popup doesn't work, and the popup won't display on the queried feature.
1. I assumed the search results would be projected to the map.spatialReference because I set up the outSpatialReference. But my result features were still in State Plane
2. Next, I tried to set the initialViewProperties to State Plane in the map. I get an error saying the wkid is null or undefined
3. Then, I tried to set the spatialReference in the MapView. I get an error saying the wkid is null or undefined
4. Finally, I tried to project my search results on the fly from State Plane to Web Mercator. I get no errors, but the feature is still in State Plane from what I can tell by selecting a point from the path in my polyline and showing the x,y
values when I display the popup.
Here
Here is my require statement:
Solved! Go to Solution.
The Map doesn't have a spatialReference in 4.0, but the View does.
MapView | API Reference | ArcGIS API for JavaScript 4.0
So you can do something like
view.then(function() { query.outSpatialReference = view.spatialReference; // continue rest of code });
The Map doesn't have a spatialReference in 4.0, but the View does.
MapView | API Reference | ArcGIS API for JavaScript 4.0
So you can do something like
view.then(function() { query.outSpatialReference = view.spatialReference; // continue rest of code });
And to clarify on this, it is because technically you can have the same map displayed in multiple MapViews and SceneViews with different spatial references. So it is the View that defines how the map is rendered, extents, center, spatial reference and so on.
Rene,
Your explanation makes sense. Thanks!!
This worked after I did two things:
1. I changed my query parameter to outSpatialReference: view.spatialReference however that still didn't work because my parameters were set before the "view.then(function() {}"
2. I added the line, like you showed above