Hi, I have a client side only feature layer that I add graphics to based on external data. When I use mapView.goTo(featureLayer.source) it properly changes the zoom and panning to bring all graphics into view. However it does not take into account the sizing of the graphics themselves so while the points are all view some graphics will be cut off out of full view.
Is there a way to goTo a collection of graphics but give it a buffer so that it goes out far enough to ensure the graphics are fully in view? I can determine the buffer myself but cant find in the documentation how to do this.
Thanks
Solved! Go to Solution.
Jason,
Now it makes sense that your zoom is -1 then. The zoom comes from the LODs of a basemap. So you need to sets the mapView.scale then instead.
To clarify, I would like whatever the zoom level is determined from the goTo to be +1 of whatever it would calculate
Jason,
I don't see a way to do this in one step (currently in the API) but you could do
mapView.goTo(featureLayer.source).then(function(){mapView.zoom = mapView.zoom + 1});
I actually tried that. mapView.zoom is -1 at this time and even if I hard code setting zoom to a value of 4 if I inspect the value after setting it its still -1 so its as if the setter is throwing the value away. maybe its "isInteracting" or something and you cant change the zoom while its interacting?
Jason,
Well the first thing I would try is setTimeout in the then function then to see if it is a timing issue.
mapView.goTo(featureLayer.source).then(function(){setTimeout(function(){mapView.zoom = mapView.zoom + 1}, 50)});
tried that. same issue. -1 before the goTo, -1 after the goTo, -1 after the setTimeout (I waited 1000ms), -1 after I try to set it to any value
Jason,
So does your map have a basemap?
it does not. loading a mapserver using Layer.fromArcGisServerUrl then adding a dynamic feature layer on top of that that I then add points to manually based on external data
Jason,
Now it makes sense that your zoom is -1 then. The zoom comes from the LODs of a basemap. So you need to sets the mapView.scale then instead.
That worked! I multiply the scale by 1.1 after the goTo and my visuals are fully in view. However now it kind of jumps around a little