Hello All,
I am trying to write a widget using WAB 2.16 that needs to be able to center and zoom upon startup. I created an event handler for the map click event as a test, and tried the following code inside:
Nothing happens upon calling the centerAndZoom method and I get the following error in the console:
"Unable to get property 'resolution' of undefined or null reference"
What did I miss?
Thank you.
Damon,
Have you verified that this.map is not null in your code scope?
Hi Robert,
I was able to console.log the map object.
Strange. Can I see your code?
Sure:
Damon,
Sorry I missed this before. The second argument on the centerAndZoom method is LevelOrFactor. But 0.5 as your code has is only applicable to a map that is using a ArcGISDynamic Map service as it's basemap.
When using an ArcGISTiledMapServiceLayer, the map is zoomed to the level specified.
When using a DynamicMapServiceLayer, the map is zoomed in or out by the specified factor. For example, use 0.5 to zoom in twice as far and 2.0 to zoom out twice as far.
Change your 0.5 to a LOD of the base map like 16 and the error is gone.