btfou

graphicsExtent and the single point

Discussion created by btfou on Sep 30, 2013
Latest reply on Jun 5, 2014 by btfou
JS API Team,
Calling graphicsExtent with a single point returns null. I get why this happens, i.e. a single point doesn't have an extent (height and width = 0). When iterating through graphics and zooming to one graphic I can understand filtering in code. For example:

zoomTo: function (gId) {
  array.forEach(this.map.resultsLayer.graphics, function (graphic) {
    if (graphic.gId === gId) {
      if (graphic.geometry.type === 'point') {
        this.map.centerAndZoom(graphic.geometry, 18);
      } else {
        this.map.setExtent(graphic.geometry.getExtent(), true);
      }
      return;
    }
  });
}


I don't mind checking for a single point myself and handling it, but it seems to me graphicsExtent should catch a single point in the graphics array and return a valid extent. Perhaps with a second parameter that when set to true returns a computed extent for a single point. I'm not sure what that would look like from the api's point of view, but something that comes to mind is returning an extent based on map size at the largest level of detail with the point as the center.

Just a suggestion and as always keep up the good work.

Outcomes