Select to view content in your preferred language

4.2 goTo collection of graphics with buffer

2572
14
Jump to solution
01-25-2017 09:22 AM
JasonRainwater
New Contributor II

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

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

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.

View solution in original post

14 Replies
JasonRainwater
New Contributor II

To clarify, I would like whatever the zoom level is determined from the goTo to be +1 of whatever it would calculate

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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});
0 Kudos
JasonRainwater
New Contributor II

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?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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)});
0 Kudos
JasonRainwater
New Contributor II

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

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jason,

  So does your map have a basemap?

0 Kudos
JasonRainwater
New Contributor II

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

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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.

JasonRainwater
New Contributor II

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

0 Kudos