How to use the @terrestris/ol-util/dist/MapUtil/MapUtil.getScaleForResolution 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
resolutions: testResolutions
      });
      const wrapper = TestUtil.mountComponent(ScaleCombo, {
        scales: [],
        map: map
      });

      // 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(testResolutions.length);

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

      expect(scales[0]).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);
  }