How to use the @terrestris/ol-util/dist/MapUtil/MapUtil.roundScale function in @terrestris/ol-util

To help you get started, we’ve selected a few @terrestris/ol-util 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 terrestris / react-geo / src / Field / ScaleCombo / ScaleCombo.spec.tsx View on Github external
const wrapper = TestUtil.mountComponent(ScaleCombo, {
        map: map,
        scales: [],
        resolutionsFilter
      });

      // Reset the scales array, as getOptionsFromMap() will be called in
      // constructor.
      wrapper.setState({'scales': []});

      const scales = wrapper.instance().getOptionsFromMap();
      expect(scales).toBeInstanceOf(Array);
      expect(scales).toHaveLength(expectedLength);

      let roundScale = MapUtil.roundScale(MapUtil.getScaleForResolution(
        testResolutions[testResolutions.length - 2] ,'m'));

      expect(scales[1]).toBe(roundScale);

      TestUtil.removeMap(map);
    });
  });
github terrestris / react-geo / src / Field / ScaleCombo / ScaleCombo.tsx View on Github external
pushScale = (scales: string[], resolution: number, view: OlView) => {
    let scale = MapUtil.getScaleForResolution(resolution, view.getProjection().getUnits());
    const roundScale = MapUtil.roundScale(scale);
    if (scales.includes(roundScale) ) {
      return;
    }
    scales.push(roundScale);
  }