Hi, I have a pretty interesting task which involves rendering the map with a GeoJSON layer and symbols for the data. I then need to take a screenshot of this map. The map is being rendered off screen on purpose and the screenshot is being taken programmatically via arcGis API. When the view is ready, I go to the desired location of the geojson with 0 animation.
The problem I am having, is the screenshot is empty. I believe the map and geojson with symbol doesn’t appear to be rendered yet. I am watching for the update on the view for when it is done moving to the location and then timing out for 2s. It inconsistently takes a screenshot.
Is there some process to know when the map and all the layers are done rendering? So, after further investigation, `queryExtent()` in combination with `goTo()` (https://developers.arcgis.com/javascript/latest/sample-code/featurelayer-queryextent/) is actually zooming in so far that the screen turns white. The GeoJsonLayer I have is definitely big enough that it covers like 10 square meters. However, if I click the Zoom (-) button 3 times, I can see my layer just fine now.
So, I think I know what the issue is. The spatial reference of the GeoJSONLayer is different than the View's spatial reference. Should I be setting the GeoJSONLayer spatial reference to be equal to the View?
Solved! Go to Solution.
Yes, I'd recommend to make them both have the same spatial reference.
The following link is a good example of how to change view's spatial reference / projection. You can also add the GeoJSONLayer's spatial reference to the dropdown list in the code to check it out:
Hi @developerarce
I would suggest checking this code sample: https://developers.arcgis.com/javascript/latest/sample-code/watch-for-changes/
It demonstrate how to check the status of the map view if moving/panning or at stationary. You can extend it to check for layers properties like "loadStatus" to detect if a layer finished loading or still loading.
Regards
Ihab
So, I think I know what the issue is. The spatial reference of the GeoJSONLayer is different than the View's spatial reference. Should I be setting the GeoJSONLayer spatial reference to be equal to the View?
Yes, I'd recommend to make them both have the same spatial reference.
The following link is a good example of how to change view's spatial reference / projection. You can also add the GeoJSONLayer's spatial reference to the dropdown list in the code to check it out:
Yeah, I think that's my issue with `queryExtent()` because the view is in Web Mercator and the GeoJSONLayer is in WSG84, so when we `gotTo()` on the view using the extent of the GeoJSONLayer. Going to give this a shot really quick.