I am using JS 4x and have developed a functionality that draws a graphic point layer on the map when it satisfies a query for a feature layer. When the functionality runs, it would be ideal if the map can zoom to the extent of the graphic layer.
However, using the code
graphicLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">when</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">function</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN>
view<SPAN class="punctuation token">.</SPAN>extent <SPAN class="operator token">=</SPAN> graphicLayer<SPAN class="punctuation token">.</SPAN>fullExtent<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>I still could not achieve the zooming to extent functionality. In some cases it zooms to the entire extent of the basemap and in some cases not. Even that was a bit bizarre.
Would someone please point out how to achieve this functionality?
Some additional information:
I also read online that a mismatch in spatial reference could be a cause of the queryExtent() feature not working and I assumed it might be the same reason for the fullExtent.
Originally,
Basemap - 3857 Web Mercator Projection (topo-vector from ESRI)
Queried feature Layer - 28992 RD-New
Graphic Layer - 4326 (for container) but 28992 for features returned
I also changed the basemap to RD-New but I am unable to set the graphic layer container projection using the following line of code.
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>graphicLayer<SPAN class="punctuation token">.</SPAN>outSpatialReference <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>view<SPAN class="punctuation token">.</SPAN>spatialReference<SPAN class="punctuation token">;</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN></SPAN>
I also checked online that it is not possible to set it. If this has been updated, it would be nice to know.
However, I am performing another function to zoomToExtent of a feature layer using the queryExtent() function and despite the mismatch between the basemap projection and the feature layer projection, that works!
Any pointers to achieve this would be very helpful!
Thank you.