How to use the viewport-mercator-project.fitBounds function in viewport-mercator-project

To help you get started, we’ve selected a few viewport-mercator-project examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / incubator-superset / superset / assets / src / visualizations / deckgl / layers / common.jsx View on Github external
export function fitViewport(viewport, points, padding = 10) {
  try {
    const bounds = getBounds(points);
    return {
      ...viewport,
      ...fitBounds({
        height: viewport.height,
        width: viewport.width,
        padding,
        bounds,
      }),
    };
  } catch (e) {
    /* eslint no-console: 0 */
    console.error('Could not auto zoom', e);
    return viewport;
  }
}
github apache / incubator-superset / superset / assets / src / visualizations / deckgl / layers / common.jsx View on Github external
export function fitViewport(viewport, points, padding = 10) {
  try {
    const bounds = getBounds(points);
    return {
      ...viewport,
      ...fitBounds({
        height: viewport.height,
        width: viewport.width,
        padding,
        bounds,
      }),
    };
  } catch (e) {
    /* eslint no-console: 0 */
    console.error('Could not auto zoom', e);
    return viewport;
  }
}
github uber-archive / viewport-mercator-project / test / spec / fit-bounds.spec.js View on Github external
test('fitBounds', (t) => {
  for (const [input, expected] of FITBOUNDS_TEST_CASES) {
    const result = fitBounds(input);

    t.ok(Number.isFinite(result.longitude), 'get valid longitude');
    t.ok(Number.isFinite(result.latitude), 'get valid latitude');
    t.ok(Number.isFinite(result.zoom), 'get valid zoom');
    t.deepEqual(
      toLowPrecision(result),
      toLowPrecision(expected),
      'valid viewport returned'
    );
  }
  t.end();
});
github GlobalFishingWatch / map-client / app / src / map / mapViewportActions.js View on Github external
export const fitBoundsToTrack = trackBounds => (dispatch, getState) => {
  const vp = fitBounds({
    bounds: [[trackBounds.minLng, trackBounds.minLat], [trackBounds.maxLng, trackBounds.maxLat]],
    width: getState().mapViewport.viewport.width,
    height: getState().mapViewport.viewport.height,
    padding: 50
  });
  dispatch(updateZoom(null, vp.latitude, vp.longitude, vp.zoom));
};